srtm2grd_readme.txt 24 february 2005, modified 29 apr 2006 lhsu and apel Instructions for making a GMT-ready DEM [.grd file] from SRTM .hgt files. ********* (1) Download SRTM files. A place to start is http://www2.jpl.nasa.gov/srtm/ Download a rectangular block if you are going to follow these directions exactly, since the grdmerge command can only paste together two blocks with edges of the same length. (2) Copy or create the example files (included at end of this file): grdraster.info srtm2grd gridmerge (3) Edit grdraster.info to list the information for each of your SRTM files grdraster.info can only be used for 30 files at a time. If you want to convert more than 30 .hgt files in .grd files they must be batched into groups of 30 or less. You probably only need to change (1) the ID number (2) the -R lat/lon specification (3) the file location There is additional documentation in the file itself. (4) Place grdraster.info in your ~/GMT directory (5) Make sure your .cshrc file has this line: setenv GMT_GRIDDIR /home/[your subdirectory, 'u2' or 'u3']/[your username]/gmt example: setenv GMT_GRIDDIR /home/u3/lhsu/gmt (6) Edit the srtm2grd file (again, the ID, -R, and file location are the entities you probably need to change) example: grdraster 450 -R83/84/36/37 -I0.05m -G$ /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E083.grd -V (7) Make sure your srtm2grd file is executable (chmod 711 srtm2grd) and run (8) Edit the gridmerge script for your geographic location, or use the grdpaste command manually to create your full block (9) Use GMT (for example grdimage) to create an image example: grdimage [yourgridfile.grd] -E300 -CGMT_relief.cpt -J$ {projection} -R${range} -P -K -O -V >> ${psfile} Example files: -------------- grdraster.info -------------- # @(#)grdraster.info 1.6 10/08/00 # # This file contains information on rasterfiles which are readable with grdraster. # This file must be named $(GMT_GRIDDIR)/grdraster.info where GMT_GRIDDIR is an # environmental variable [$GMTHOME/share/dbase]. This file is read by grdraster at # run time. Any line beginning with a # will be treated as a comment, and blank # lines are skipped. Any other line must have the following items, all on one # line, one line per rasterfile: # # file_number "title string" "z units" -R -I GorP type scale offset NaNflag filename [S] # # There must be white space between each item. "title string" and "z units" must # be enclosed in " ", and they may have white space within them. They are limited # to a maximum of 80 characters. No other quotation marks should be on a line. # The entire line should be writable in 320 characters. # # file_number is an integer used to tell grdraster which raster to read. It must # be unique to each raster. # "title string" is a brief description of the data. # "z units" describes the units of the data after they are scaled and offset. # -R/// describes the range of the raster in the usual GMT -R manner. # -I/ describes the sampling interval in the usual GMT -I manner. # GorP is either G or P, indicating Grid or Pixel registration. # type is one of the following, indicating the kind of data stored in the raster: # b bit data, either 0 or 1, one bit per data value. # u unsigned character data. # c signed character data. # d unsigned two-byte integer data. # i signed two-byte integer data. # scale is a number which should be multiplied on the raster value after read. # offset is a number which should be added to the [scaled] raster value. # NaNflag is a number which is written in the raster to represent NaN. # If all values in the raster represent data, NaNflag is none. # filename is the name the raster file. If filename begins with a "/", then # it will be treated as a complete name. If not, the complete name will # be formed as $(GMT_GRIDDIR)/filename. # Optionally, you may append a single character S to indicate that this data set # needs to be byte swapped on this machine. Because binary data sets are not # architecture-independent a file written on, say, a Solaris computer will have # a different byte order than a PC (Linux or WIN32). You have two alternative # ways to deal with this: 1. Compile in byte swapping. This occurs if the # define flag -DGMTSWAP is given to the compiler, and is the default action when # installing GMT using installgmt if the byte order differs from that of a Sun. # 2. Append the swap flag for those data sets that need it. # # You will need to edit this to reflect which data you have installed on your # system, and append S for swapping if appropriate: # 437 "SRTM Global Topography" "m" -R70/71/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E070.hgt 438 "SRTM Global Topography" "m" -R71/72/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E071.hgt 439 "SRTM Global Topography" "m" -R72/73/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E072.hgt 440 "SRTM Global Topography" "m" -R73/74/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E073.hgt 441 "SRTM Global Topography" "m" -R74/75/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E074.hgt 442 "SRTM Global Topography" "m" -R75/76/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E075.hgt 443 "SRTM Global Topography" "m" -R76/77/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E076.hgt 444 "SRTM Global Topography" "m" -R77/78/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E077.hgt 445 "SRTM Global Topography" "m" -R78/79/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E078.hgt 446 "SRTM Global Topography" "m" -R79/80/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E079.hgt 447 "SRTM Global Topography" "m" -R80/81/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E080.hgt 448 "SRTM Global Topography" "m" -R81/82/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E081.hgt 449 "SRTM Global Topography" "m" -R82/83/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E082.hgt 450 "SRTM Global Topography" "m" -R83/84/36/37 -I0.05m G i 1 0 -32768 /data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E083.hgt -------- srtm2grd -------- grdraster 437 -R70/71/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E070.grd -V grdraster 438 -R71/72/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E071.grd -V grdraster 439 -R72/73/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E072.grd -V grdraster 440 -R73/74/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E073.grd -V grdraster 441 -R74/75/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E074.grd -V grdraster 442 -R75/76/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E075.grd -V grdraster 443 -R76/77/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E076.grd -V grdraster 444 -R77/78/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E077.grd -V grdraster 445 -R78/79/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E078.grd -V grdraster 446 -R79/80/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E079.grd -V grdraster 447 -R80/81/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E080.grd -V grdraster 448 -R81/82/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E081.grd -V grdraster 449 -R82/83/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E082.grd -V grdraster 450 -R83/84/36/37 -I0.05m -G/data/vel4/AT/GMT/WORLDTOPO/INDIA/N36E083.grd -V --------- gridmerge --------- #!/bin/sh # merge GMT .grd files incrementially # #-------------------------------------# # Starting Longitude # A=60 B=`expr $A + 1` C=`expr $B + 1` # Ending Longitude # D=89 # Latitude # lat=28E0 grdpaste N$lat$A.grd N$lat$B.grd -GN$lat$A$B.grd -V while [ $B != $D ] do grdpaste N$lat$A$B.grd N$lat$C.grd -GN$lat$A$C.grd -V 'rm' N$lat$A$B.grd B=`expr $B + 1` C=`expr $C + 1` done