This is my bash script file to burn up a map of Cyprus. If anyone is interested, leave a comment and I'll throw up where to get and install the libraries, ASTERS and the mapbox tools. The basic sequence is as follows:
- merge all the ASTER DEM files to one big block covering all of Cyprus
- convert the projection to mercator
- create hillshade from the DEM file, and clip
- create the color relief, and clip
- create slopeshade, and clip
- merge the hillshade and color relief, and clip
Note each type of file created is clipped with a shape file of Cyprus which allows me to use any file to overlay in tilemill and serve with tileserver on Ubuntu.
This was done on a Mac but has been used on a linux box (fedora and ubuntu).
source ~/.bash_profile
echo merging multiple aster files ASTGTM2_N34E032_dem.tif into file [cyprus-aster.tif] ...
gdal_merge.py -o cyprus-aster.tif ASTGTM2_N34E032_dem.tif ASTGTM2_N34E033_dem.tif ASTGTM2_N34E034_dem.tif ASTGTM2_N34E035_dem.tif ASTGTM2_N35E032_dem.tif ASTGTM2_N35E033_dem.tif ASTGTM2_N35E034_dem.tif ASTGTM2_N35E035_dem.tif
gdalinfo -mm cyprus-aster.tif
echo warping cyprus-aster.tif from 4326 to 3785 into file [cyprus-aster-3785.tif]....
gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3785 -r lanczos cyprus-aster.tif cyprus-aster-3785.tif
gdalinfo -mm cyprus-aster-3785.tif
########### HILLSHADE ######
echo creating hillshade of cyprus-aster-3785.tif into file [hillshade.tif]....
gdaldem hillshade cyprus-aster-3785.tif hillshade.tif -compute_edges
gdalinfo -mm hillshade.tif
echo clipping hillshade inot file [hillshade-clipped.tif]...
rm -f hillshade-clipped.tif
gdalwarp -co compress=deflate -dstnodata 255 -cutline c.shp hillshade.tif hillshade-clipped.tif
############# COLOR RELIEF #############
echo creating color-relief of cyprus-aster.tif into file [relief.tif]
gdaldem color-relief cyprus-aster-3785.tif ramp-dark-white-red-green-khaki.txt relief.tif
echo clipping relief....
rm -f relief-clipped.tif
gdalwarp -co compress=lzw -dstalpha -cutline c.shp relief.tif relief-clipped.tif
################# SLOPE #############
echo making a slope relief
gdaldem slope cyprus-aster-3785.tif slope.tif
#echo clipping slope....
rm -f slope-clipped.tif
gdalwarp -co compress=deflate -dstnodata 255 -cutline c.shp slope.tif slope-clipped.tif
echo adding slope from slop-ramp.txt into file slopeshade.tif
gdaldem color-relief slope.tif slope-ramp.txt slopeshade.tif
#echo clipping slopeshade....
rm -f slopeshade-clipped.tif
#gdalwarp -co compress=deflate -dstnodata 255 -cutline c.shp slopeshade.tif slopeshade-clipped.tif
gdalwarp -co compress=lzw -dstalpha -cutline c.shp slopeshade.tif slopeshade-clipped.tif
########## RELIEF AND HILLSHADE ##############
echo merging color-relief and hillshade into file [relief-hillshade.tif]
./hsv_merge.py relief.tif hillshade.tif relief-hillshade.tif
########## CLIPPING ################
echo removing any old files before creating the final version
rm -f cyprus-clipped.tif
echo cutting out cyprus and finishing... cutting out relief-hillshade.tif with cyp.shp into file [cyprus-clipped.tif]
gdalwarp -co compress=deflate -dstnodata 255 -cutline c.shp relief-hillshade.tif cyprus-clipped.tif
No comments:
Post a Comment