5

Does anybody know how to read a NASA .hgt file in C#?

Apparently the question was asked in Python here: how to read NASA .hgt binary files

Community
  • 1
  • 1
zetar
  • 1,225
  • 2
  • 20
  • 45

1 Answers1

4

Use GDAL library (geographic data abstraction layer): it supports HGT files and it has C# binding using SWIG.

Edit: all you information you need is here.

From the FAQ:

The SRTM data files have names like "N34W119.hgt". What do the letters and numbers refer to, and what is ".hgt" format?

Each data file covers a one-degree-of-latitude by one-degree-of-longitude block of Earth's surface. The first seven characters indicate the southwest corner of the block, with N, S, E, and W referring to north, south, east, and west. Thus, the "N34W119.hgt" file covers latitudes 34 to 35 North and longitudes 118-119 West (this file includes downtown Los Angeles, California). The filename extension ".hgt" simply stands for the word "height", meaning elevation. It is NOT a format type. These files are in "raw" format (no headers and not compressed), 16-bit signed integers, elevation measured in meters above sea level, in a "geographic" (latitude and longitude array) projection, with data voids indicated by -32768. International 3-arc-second files have 1201 columns and 1201 rows of data, with a total filesize of 2,884,802 bytes ( = 1201 x 1201 x 2). United States 1-arc-second files have 3601 columns and 3601 rows of data, with a total filesize of 25,934,402 bytes ( = 3601 x 3601 x 2). For more information read the text file "SRTM_Topo.txt" at http://edcftp.cr.usgs.gov/pub/data/srtm/Readme.html

Luca
  • 11,646
  • 11
  • 70
  • 125
  • I can't use GDAL or external libraries. – zetar Oct 25 '12 at 18:46
  • Sorry, hit return... and well... anyway, is there a header in the file? How do you know the length of the file (apparently they come in two flavors)? – zetar Oct 25 '12 at 18:46
  • Also, is the file name the only way to know that coordinates of the file itself? – zetar Oct 25 '12 at 18:51
  • See my edits. Hope they help. ANd to just confirm, yes, the terrain chunk coordinates are derivable only by the file name (just checked GDAL sources). – Luca Oct 26 '12 at 19:30
  • @zetar - Why can't you use GDAL or external libraries. If thats really is the case then write your own library to do so. – Security Hound Nov 19 '12 at 19:25