[Gdal-dev] SRTM .hgt generation

Frank Warmerdam warmerdam at pobox.com
Wed Oct 18 09:31:05 EDT 2006


maestrini_andrea at virgilio.it wrote:
>  Hi!
> 
> Can you help me in converting .dem format into .hgt format (for
> Radio Mobile tool that used SRTM maps )?
> I have converted .asc format
> in .dem format with Gdal, but Radio Mobile works with SRTM format
> (Radio Mobile uses .hgt format) it doesn't work with .dem!!!

Andrea,

I *think* that .hgt files are just raw 16bit raster files with a particular
product size and a particular resolution/extent.  This could be produced by
GDAL but I don't know the srtm particulars off hand.

OK, I skimmed the GRASS r.in.srtm script for particulars, and I it looks like
SRTM .hgt files are 1 degree by 1 degree files of 1201 x 1201 pixels, with
16bit data.  The files seem to be named stuff like e100s10.hgt.

To produce something like the e100s10.hgt file you should be able to do
something like:

gdalwarp -of EHDR -ot Int16 -te 100 9 101 10 -ts 1201 1201 -rb \
          in.tif e100s10.hgt

then delete e100s10.hdr, and e100s10.prj which you shouldn't need.

Ah, shoot, I see that .hgt files need to be in big endian order which is
not the default for the EHDR writer.  So in fact you will need to do:

gdalwarp -of EHDR -ot Int16 -te 100 9 101 10 -ts 1201 1201 -rb \
          in.tif e100s10.hgt

edit e100s10.hdr, modify "BYTEORDER   I" to "BYTEORDER   M" and then rerun
the warp:

gdalwarp -of EHDR -rb in.tif e100s10.hgt

You will need to take care to produce only tiles for regions you have input
data for.

I have taken the liberty of cc:ing gdal-dev in case this is of interest to
others.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list