Created
September 25, 2019 18:58
-
-
Save samtux/9be76fd2725208a32ac4dda9abedb92d to your computer and use it in GitHub Desktop.
Convertir una tabla XLSX de puntos a rutas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Fecha: 25 de septiembre de 2019 | |
# Descripcion: Convertir una tabla XLSX de puntos a rutas | |
for filename in *.xlsx; | |
do | |
archivo="${filename%.*}" | |
echo "Construyendo los puntos a partir de la hoja de EXCEL $archivo" | |
ogr2ogr -f "GPKG" -geomfield geom -dialect sqlite -sql "SELECT *, GeomFromText('POINT Z(' || CAST( x AS integer) || ' ' || CAST( y AS integer) || ' ' || CAST (altitud AS integer) || ')', 3116 ) AS geom FROM Sheet1" --config OGR_XLSX_HEADERS FORCE $archivo.gpkg $archivo.xlsx | |
ogrinfo $archivo.gpkg -sql "ALTER TABLE SELECT RENAME TO vertices" | |
echo "Construyendo la ruta a partir de la capa de puntos" | |
ogr2ogr -update -dialect sqlite -sql "SELECT 'user_id', MakeLine(geom) FROM vertices GROUP BY 'user_id'" $archivo.gpkg $archivo.gpkg | |
ogrinfo $archivo.gpkg -sql "ALTER TABLE SELECT RENAME TO ruta" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment