Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
http://tinitaly.pi.ingv.it/Download_Area2.html (per avviare lo script, digitare: sh scriptDTM_Sicilia10mOSGeo4W.sh
#!/bin/bash
# scarica tutti i tasselli della Sicilia TINITALY DEM 10m/px CC BY 4.0
### requisiti ###
# OSGeo4W Shell
# WIndows 10 Versione 1903 o superiori
# curl https://curl.haxx.se/
# tar https://www.gnu.org/software/tar/tar.html
# ogr2ogr https://gdal.org/programs/ogr2ogr.html <3
# aborruso https://twitter.com/aborruso
### 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
curl "http://tinitaly.pi.ingv.it/data/"$i"_s10/"$i"_s10.zip" -o "$i"_s10.zip
# vai nella cartella processing
cd "$folder"/processing/
# unzippa il file
tar -xf "$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 merged.tif 2 4 8 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment