Skip to content

Instantly share code, notes, and snippets.

@mtreg
Last active August 29, 2015 14:11
Show Gist options
  • Save mtreg/1cdcd5bc4fb246e2b667 to your computer and use it in GitHub Desktop.
Save mtreg/1cdcd5bc4fb246e2b667 to your computer and use it in GitHub Desktop.
Download, Unzip, Mosaic, and Reproject National Elevation Dataset 1/3 arcsecond
#All of this tested in in Cygwin on Windows 7 x64
#Requires GDAL, Cygwin (or other *nix terminal) with wget and unzip installed; also requires an installation of Python
#GDAL should be in system PATH
#To download files based on a hand-made text file called "URLZipList.txt" - list of all the .zip filenames needed (files from here: ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/13/IMG/):
#Example file name: "ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/1/IMG/n39w096.zip"
wget -i URLZipList.txt
#Unzip all files to respective folders
for z in *.zip; do
d=`basename $z .zip`
mkdir $d && unzip $z -d $d
done
#Run gdal_merge.py to create mosaic DEM (from: https://github.com/RENCI-Ecohydro/OSS-2014/blob/master/Scripts/gdal_merge_example.sh); either of the two lines below will work (the first one makes the previous command unnecessary
C:/Anaconda/python.exe C:/OSGeo4w64/bin/gdal_merge.py -o n35w092_n39_w096_30m.tif */*.img
# First argument is path to local python
# second argument is path to gdal_merge.py
# third argument is output filename
#Fourth argument ('*/*.img') specifies all .img files in all subfolders
#Complete details for gdal_merge.py here: http://www.gdal.org/gdal_merge.html
#To reproject to UTM zone 15 with cubic resampling
gdalwarp -t_srs '+proj=utm +zone=15 +datum=WGS84' -r cubic n35w092_n39_w096_30m.tif n35w092_n39_w096_30m_UTM_cubic.tif
#See documentation for GDALWarp here: http://www.gdal.org/gdalwarp.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment