QGIS – How to Open .hgts File from NASADEM Data

cdemhgtnasademqgis

I have the NASA SRTM1 data as .hgt files from their ftp website, but I would have these elevation data in respect to WGS84. I found by NASA's ftp site a folder named srtmOnly that contains what I want, but they have the extension .hgts not .hgt

I found just these infos in readme file

Directory: hgt_srtmOnly

product description: SRTM-only floating point DEM (*.hgts)

product data type: 4-byte real

hgt_srtmOnly contains heights relative to the WGS84 ellipsoid

hgts meters (with value set to -32768 for a void in hgt_srtmOnly hgts
files)

I tried to open it with Qgis as raster but it didnt be recognized, also I have a code c++ that converts .hgt file to .csv also doesnt work with these .hgts file.

Does anyone have an idea how to get these data from these .hgts file?

Add
This is my cread .hdr file as adviced by @camilo

BYTEORDER M
LAYOUT BIL
NROWS 3601
NCOLS 3601
NBANDS 1
NBITS 32
BANDROWBYTES 14404
TOTALROWBYTES 14404
BANDGAPBYTES 0
NODATA -32768
ULXMAP 34
ULYMAP 36
XDIM 0.00027777777777778
YDIM 0.00027777777777778

Best Answer

Those .hgts files are in the same general format than the .hgt files, however they contain the elevation data in 4 bytes floating point numbers instead of 2 bytes integers.

Global Mapper won't recognize the .hgts extension. Therefore, when asked about the format of the data you have to choose the option "SRTM (Space Shuttle Topography Mission)".

But unfortunately that's not enough, because of the difference in the data type. Therefore you have to provide a header file (.hdr) that contain some information about how to interpret the data. Thankfully, the .hdr file is just an ascii text file, so you can create or edit it easily.

One way to get a template of the file is to download an standard .hdr file, open it in Global Mapper and then immediately export it in SRTM format. Along with the .hgt file, it will create a .hdr header file.

If you change the extension of the file to .txt and open it in a text editor it will look like this:

BYTEORDER      M
LAYOUT         BIL
NROWS          3601
NCOLS          3601
NBANDS         1
NBITS          16
BANDROWBYTES   7202
TOTALROWBYTES  7202
BANDGAPBYTES   0
NODATA         -9999
ULXMAP         -50
ULYMAP         1
XDIM           0.00027777777777778
YDIM           0.00027777777777778

To adapt this header to work with hgts files we need to change the number of bits (NBITS) from 16 to 32, the total bytes per row and column from 7202 to 14404, and the NODATA value from -9999 to -32768. Additionally, if you want to use the header for other tiles you can change the latitude and longitude of the upper left corner (ULXMAP and ULYMAP, that in this case is 50° West and 1° North).

In contrast to Global Mapper, QGIS doesn't automatically detect that the data type is float (i.e. decimal numbers), and might don't recognize the extension. To solve those problems you have to add an additional line to the header file:

PIXELTYPE      FLOAT

And you might need to change the data file extensión to .bil (instead of .hgts).

I did a test and my .hdr file ended looking like this:

BYTEORDER      M
LAYOUT         BIL
NROWS          3601
NCOLS          3601
NBANDS         1
NBITS          32
PIXELTYPE      FLOAT
BANDROWBYTES   14404
TOTALROWBYTES  14404
BANDGAPBYTES   0
NODATA         -32768
ULXMAP         -50
ULYMAP         1
XDIM           0.00027777777777778
YDIM           0.00027777777777778

After those edits, if you rename the file back to .hdr (and optionally change the .hgts extension to just .hgt for Global Mapper or .bil for QGIS). You should be able to load the file without any problem. However, my version of QGIS renders it completely white, and I had to manually adjust the limits of the gray color scale to get it to display properly.

The examples above are for the file n00w050.hgts.zip (South America folder), so instead of exporting to get an .hdr example, it might just work if you copy the text above and paste it in a text file with the same name of the .hgts file, adjust the Lat/Lon of the upper left corner, rename to .hdr and that's it.

There are also scripts to automatically generate the .hdr files, as you see they are quite simple, and write such script wouldn't take much. This newer version of the SRTM (NASADEM), is still in a preliminary release, I describe it in this answer, and there I also mention a script to generate the .hdr files, you can give that script a try, it might solve your problem without messing with the .hdr header files.

Related Question