Last active
March 15, 2018 20:34
-
-
Save pigreco/a46d13b146131288682d6864c1936397 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -x | |
#creo cartella di output | |
mkdir ./nomecartelladxf | |
mkdir ./nomecartellashp | |
#trasformo in csv lo shapefile | |
ogr2ogr -f CSV sicilia.csv sicilia.shp; | |
# estraggo la colonna che mi serve e rimuovo l'intestazione | |
csvsql --query "select SIGLA from sicilia" sicilia.csv | tail -n +2 >./sigla.csv; | |
# ciclo per splittare lo shapefile | |
while read p; do | |
ogr2ogr -f "ESRI Shapefile" -where "SIGLA ='$p'" ./nomecartellashp/$p.shp sicilia.shp; | |
done <./sigla.csv; | |
#ciclo per convertire da shp in dxf | |
for i in ./nomecartellashp/*.shp; | |
do | |
#crei una variabile che usi per estrarre nome e estensione | |
filename=$(basename "$i") | |
#estrai estensione | |
extension="${filename##*.}" | |
#estrai nome file | |
filename="${filename%.*}" | |
ogr2ogr -f DXF ./nomecartelladxf/"$filename".dxf ./"$i"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment