Commit 09220ab2 authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

script for downloading srtm tile

parent 5bf2b653
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo "Usage: $0 list_needed_srtm_tiles srtmzip/" >&2
exit 1
fi
directory="$2/"
list_needed_tiles=$1
baseurls="http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Africa
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Australia
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Islands
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/South_America"
mkdir -p $directory
cat $list_needed_tiles | while read one_line
do
lon=$(printf -- "$one_line" | cut -f 1)
lat=$(printf -- "$one_line" | cut -f 2)
if [[ $lat -ge 0 ]] # 0 is N
then
strlat=$( printf "N%02d" $lat )
else
strlat=$( printf "S%02d" $((-$lat)) )
fi
if [[ $lon -ge 0 ]] # 0 is E
then
strlon=$( printf "E%03d" $lon )
else
strlon=$( printf "W%03d" $((-$lon)) )
fi
name=$strlat$strlon.hgt
for baseurl in $baseurls
do
printf "$baseurl/$name.zip\n"
done
done | wget -c -i - -P "$directory"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment