How to Open and Inspect HGT Files — Step-by-Step Viewer GuideHGT files store elevation (height) data in a simple grid format used widely for digital elevation models (DEMs). They’re produced by projects such as NASA’s Shuttle Radar Topography Mission (SRTM) and are useful for GIS analysts, hikers, 3D modelers, geologists, and anyone working with terrain. This guide explains what HGT files are, how to open them with different tools (free and commercial), how to inspect and interpret their contents, and common troubleshooting tips.
What is an HGT file?
An HGT file is a raster file that contains elevation values arranged in a square grid. Typical characteristics:
- Resolution: Commonly 1 arc-second (~30 m) or 3 arc-seconds (~90 m).
- Format: Raw 16-bit signed integer values (big-endian) with no header; each value represents elevation in meters.
- Naming: Filenames encode geographic location, e.g., N37W122.hgt covers 37°N, 122°W.
- Coverage: Each 1°×1° tile contains (for 1-arc-second) 3601×3601 samples or (for 3-arc-second) 1201×1201 samples (note: some sources use 3600 or 1200 depending on edge handling).
Tools you can use
Below are popular viewers and GIS tools that can open HGT files:
- QGIS (free, cross-platform) — full GIS, excellent for visualization and analysis.
- GDAL (free, command-line library/tools) — conversion, inspection, and scripting.
- Global Mapper (commercial) — robust terrain tools and visualization.
- ArcGIS (commercial) — enterprise GIS with extensive raster tools.
- MicroDEM (free, Windows) — terrain-specific viewer.
- MeshLab / Blender (free) — for making 3D meshes from heightmaps.
- Online viewers (various) — quick previews without installing software.
Step-by-step: Opening HGT files in QGIS (recommended for most users)
- Install QGIS from qgis.org for your OS.
- Launch QGIS.
- From the menu, choose Layer → Add Layer → Add Raster Layer.
- Click “…” next to “Raster dataset(s)” and select the .hgt file. QGIS will usually recognize the raster dimensions and encoding automatically.
- Click Add, then Close. The HGT will display as a grayscale elevation map.
- To apply a color hillshade or palette: open the Layer Properties → Symbology. Choose “Singleband pseudocolor” or “Hillshade” (you can generate a hillshade via the Raster → Analysis → Hillshade tool for dramatic terrain visualization).
- For metadata and statistics: Layer Properties → Information / Histogram. Use Raster → Miscellaneous → Build Virtual Raster or Translate (GDAL) to convert formats if desired.
Step-by-step: Inspecting and converting with GDAL
GDAL is ideal when you need scripted inspection or format conversion.
- Install GDAL (OSGeo4W on Windows, Homebrew on macOS, package managers on Linux).
- Quick info: run
gdalinfo N37W122.hgt
This prints raster size, data type (Int16), coordinate system (often reported as unknown for pure HGT), and min/max values (if computed).
- To convert to GeoTIFF (adds georeference and easier use):
gdal_translate -of GTiff N37W122.hgt N37W122.tif
- Compute basic statistics:
gdalinfo -stats N37W122.hgt
- View a small ASCII sample:
gdal_translate -of XYZ -b 1 N37W122.hgt sample.xyz head -n 10 sample.xyz
The XYZ format lists x (longitude), y (latitude), z (elevation) — useful for quick checks.
How to interpret the data
- Elevation values are in meters (positive above sea level, negative for below).
- Look for no-data values (commonly -32768) — these indicate missing measurements (e.g., over water or data voids). Handle them with care when analyzing.
- Edge values: neighboring HGT tiles often overlap at edges; check whether your dataset uses 3601 vs 3600 rows/columns to avoid duplicated rows when mosaicking.
- Vertical datum: SRTM heights are referenced to the EGM96 geoid or WGS84 ellipsoid depending on processing — verify if you need orthometric vs ellipsoidal heights for precise work.
Generating visualizations and analyses
- Hillshades: create shaded relief to emphasize terrain:
- QGIS: Raster → Analysis → Hillshade.
- GDAL: use gdaldem hillshade.
- Slope and aspect: Raster → Terrain Analysis tools in QGIS; gdaldem slope/aspect as command-line alternatives.
- Contours: Raster → Extraction → Contour in QGIS or gdal_contour.
- 3D meshes: export the HGT to a grayscale TIFF, then import into Blender or MeshLab. In Blender, use the TIFF as a displacement map on a subdivided plane; in MeshLab use “Height Field to Mesh” filters.
- Mosaicking many tiles: use QGIS’s “Build Virtual Raster” or gdal_merge/gdalwarp for reprojection and merging.
Common issues and troubleshooting
- “Blank” or black image: ensure the data type and value range are correctly interpreted. Use Layer Properties → Symbology to set min/max or stretch.
- Wrong georeference: raw HGT lacks an embedded CRS in some cases; ensure you assign EPSG:4326 (WGS84 geographic) when needed. In GDAL:
gdal_translate -a_srs EPSG:4326 N37W122.hgt N37W122_geo.tif
- Missing data / voids: fill small voids with interpolation (QGIS Raster → Analysis → Fill nodata) or use specialized SRTM void-fill datasets.
- Large files: use GDAL virtual rasters (VRT) or work on clipped subsets to save memory.
Example workflows
- Quick preview: open the HGT in QGIS, apply a pseudocolor ramp and hillshade.
- Analysis pipeline: convert HGT → GeoTIFF (gdal_translate), build VRT for many tiles (gdalbuildvrt), compute slope/aspect (gdaldem), then extract contours (gdal_contour).
- 3D printing terrain: convert to GeoTIFF, resample to needed resolution, export as 16-bit PNG or STL via Blender/MeshLab.
Tips and best practices
- Keep original HGT files unchanged; work on copies or converted GeoTIFFs.
- Use virtual rasters (VRT) for large mosaics to avoid creating huge temporary files.
- Track the vertical reference (geoid vs ellipsoid) if precise elevation is required.
- When combining tiles, trim overlapping borders to avoid duplicated rows or seams.
- For scripting, use GDAL in Python (rasterio or GDAL bindings) for reproducible processing.
Quick reference commands
- gdalinfo (inspect): gdalinfo N37W122.hgt
- Convert to GeoTIFF: gdal_translate -of GTiff N37W122.hgt N37W122.tif
- Build virtual raster: gdalbuildvrt mosaic.vrt *.hgt
- Hillshade: gdaldem hillshade input.tif hillshade.tif -z 1.0 -s 1.0
If you want, I can:
- Provide an exact command sequence for a specific OS.
- Show a short Python script using rasterio to read an HGT and plot its histogram.
- Walk through converting an HGT tile to a 3D mesh for Blender with step-by-step commands.
Leave a Reply