Created
July 14, 2013 16:48
-
-
Save yohanboniface/5994901 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env bash | |
cd src/download | |
echo ${PWD} | |
if test -z "$1" | |
then | |
echo "Use ./script/fetch.sh W,S,E,N; ex.: 58,13,59,12" | |
exit 0 | |
fi | |
A=$1 | |
BBOX=(${A//,/ }) | |
if [[ ! ${#BBOX[@]} = 4 ]] | |
then | |
echo "Bad bbox format, please use W,S,E,N" | |
exit 1 | |
fi | |
W=${BBOX[0]} | |
S=${BBOX[1]} | |
E=${BBOX[2]} | |
N=${BBOX[3]} | |
for (( x=$W; x<=$E; x++ )) | |
do | |
for (( y=$N; y<=$S; y++ )) | |
do | |
URL=http://srtm.csi.cgiar.org/SRT-ZIP/SRTM_V41/SRTM_Data_GeoTiff/srtm_$(printf "%02d" $x)_$(printf "%02d" $y).zip | |
echo "Downloading $URL" | |
wget $URL | |
done | |
done | |
echo "Done with downloads. Now unzipping" | |
for file in *.zip | |
do | |
unzip $file | |
rm readme.txt | |
rm *.hdr | |
rm *.tfw | |
done | |
rm *.zip | |
echo "Now processing tif files" | |
for file in *.tif | |
do | |
proj_name=../${file/.tif}-3785.tif | |
hillshade_name=../../hillshade/${file/.tif}-hillshade-alt80-3785.tif | |
contour_name=../../contour/${file/.tif}-contour-25m-3785.shp | |
gdalwarp -s_srs EPSG:4269 -t_srs EPSG:3785 -r bilinear $file $proj_name | |
rm $file | |
if [ ! -f "$hillshade_name" ] | |
then | |
echo "Doing hillshade for $file" | |
gdaldem hillshade -co compress=lzw $proj_name $hillshade_name -alt 80 | |
fi | |
if [ ! -f "$contour_name" ] | |
then | |
echo "Doing contour for $file" | |
gdal_contour -a height $proj_name $contour_name -i 25.0 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice work.