Last active
September 8, 2020 18:36
-
-
Save pigreco/b0acf8e6f44277fb0d9925ebe4c1bf86 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 | |
# scarica tutti i tasselli della Sicilia TINITALY DEM 10m/px CC BY 4.0 | |
### requisiti ### | |
# wget https://www.gnu.org/software/wget/ | |
# 7z https://www.7-zip.org/ | |
# ogr2ogr https://gdal.org/programs/ogr2ogr.html | |
# GDAL https://gdal.org/ | |
# aborruso https://twitter.com/aborruso <3 | |
### requisiti ### | |
folder="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
mkdir -p ./rawdata | |
mkdir -p ./processing | |
# cancella file | |
rm -r "$folder"/rawdata/* | |
rm -r "$folder"/processing/* | |
rm -r "$folder"/out*.txt | |
# crea lista nomi celle per la Sicilia cod_reg= 19 | |
ogr2ogr -f CSV -dialect sqlite -sql "SELECT ID FROM Reg01012020_g_WGS84 r, './Quadro_unione/_qu_retiled_32.shp'._qu_retiled_32 u where cod_reg= 19 and st_intersects (u.geometry, r.geometry) = 1" output.csv ./Reg01012020_g/Reg01012020_g_WGS84.shp | |
# togli prima riga | |
tail -n +2 output.csv >out1.txt | |
# elimina _10 finale | |
sed -e 's/_10//' out1.txt >lista.txt | |
# fai un ciclo per ogni tassello della Sicilia | |
for i in $(cat lista.txt) | |
do | |
# vai nella cartella rawdata | |
cd "$folder"/rawdata/ | |
# scarica il file zip | |
wget http://tinitaly.pi.ingv.it/data/"$i"_s10/"$i"_s10.zip | |
# vai nella cartella processing | |
cd "$folder"/processing/ | |
# unzippa il file | |
7z x "$folder"/rawdata/"$i"_s10.zip | |
# sposto file | |
mv "$folder"/processing/"$i"_s10/"$i"_s10.tif "$folder"/processing/ | |
# cancella le cartelle inutili | |
rmdir "$folder"/processing/"$i"_s10 | |
done | |
# vai nella cartella processing e crea lista dei file tif | |
cd "$folder"/processing/ | |
ls *.tif >list.txt | |
# mergia tutti i file e tasselali | |
gdal_merge.py -o merged.tif -co "TILED=YES" -co "BLOCKXSIZE=512" -co "BLOCKYSIZE=512" -co "COMPRESS=DEFLATE" -co "ZLEVEL=9" -co "BIGTIFF=YES" -init -9999 -a_nodata -9999 -n -9999 -ot Float32 --optfile list.txt | |
# crea piramidi | |
gdaladdo -r nearest --config COMPRESS_OVERVIEW DEFLATE --config GDAL_TIFF_OVR_BLOCKSIZE 512 "$folder"/processing/merged.tif 2 4 8 16 |
crea lista nomi celle per la Sicilia
ogr2ogr -f CSV -dialect sqlite -sql "SELECT ID FROM Reg01012020_g_WGS84 r, './Quadro_unione/_qu_retiled_32.shp'._qu_retiled_32 u where cod_reg= 19 and st_intersects (u.geometry, r.geometry) = 1" output.csv ./Reg01012020_g/Reg01012020_g_WGS84.shp
# togli prima riga
tail -n +2 output.csv >out1.txt
# elimina _10 finale
sed -e 's/_10//' out1.txt >out2.txt
Nel ciclo for
usare il file out2.txt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@aborruso
da aggiungere allo script di sopra per il
merge
,tassellazione
epiramidazione