GeoTIFF to SRTM – How to Convert a TIFF File to an HGT File using GDAL

gdal-translategdalwarpgeotiff-tiffsrtm

In my project I needed to convert TIFF file to SRTM data and came up with following warning/error.

gdal_translate -of SRTMHGT Terrain.tif Terrain.hgt

Output:

    Warning 1: The source projection coordinate system is PROJCS["RGF93 / CC48",GEOGCS["RGF93",DATUM["Reseau_Geodesique_Francais_1993",SPHEROID["GRS 1980",637813
    7,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6171"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017
    4532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4171"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",47.25],PARAMETER[
    "standard_parallel_2",48.75],PARAMETER["latitude_of_origin",48],PARAMETER["central_meridian",3],PARAMETER["false_easting",1700000],PARAMETER["false_northing"
    ,7200000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","3948"]]. Only WGS 84 is supported.
    The SRTMHGT driver will generate a file as if the source was WGS 84 projection coordinate system.

    Warning 1: The corner coordinates of the source are not properly aligned on plain latitude/longitude boundaries.

    ERROR 1: Image dimensions should be 1201x1201, 3601x3601 or 1801x3601.

Here is the gdalinfo of the Terrain.tif file.

Driver: GTiff/GeoTIFF
Files: Terrain.tif
Size is 375, 375
Coordinate System is:
PROJCS["RGF93 / CC48",
    GEOGCS["RGF93",
        DATUM["Reseau_Geodesique_Francais_1993",
            SPHEROID["GRS 1980",6378137,298.257222101,
                AUTHORITY["EPSG","7019"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6171"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4171"]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",47.25],
    PARAMETER["standard_parallel_2",48.75],
    PARAMETER["latitude_of_origin",48],
    PARAMETER["central_meridian",3],
    PARAMETER["false_easting",1700000],
    PARAMETER["false_northing",7200000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    AUTHORITY["EPSG","3948"]]
Origin = (1350983.998099997639656,7223238.974300000816584)
Pixel Size = (2.000000000000000,-2.000000000000000)
Metadata:
  AREA_OR_POINT=Point
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 1350983.998, 7223238.974) (  1d41'25.74"W, 48d 6'48.59"N)
Lower Left  ( 1350983.998, 7222488.974) (  1d41'23.54"W, 48d 6'24.35"N)
Upper Right ( 1351733.998, 7223238.974) (  1d40'49.55"W, 48d 6'50.06"N)
Lower Right ( 1351733.998, 7222488.974) (  1d40'47.35"W, 48d 6'25.82"N)
Center      ( 1351358.998, 7222863.974) (  1d41' 6.54"W, 48d 6'37.21"N)
Band 1 Block=375x5 Type=Float32, ColorInterp=Gray
  NoData Value=0

Best Answer

From the GDAL doc:

The driver does support creating new files, but the input data must be exactly formatted as a SRTM-3 or SRTM-1 cell. That is the size, and bounds must be appropriate for a cell.

The output of yourgdal_translate command is pretty clear. Your data needs to be in WGS84 (epsg 4326), be 1201x1201 (cellsize=0.00083333333) or 3601x3601 (cellsize=0.0002777777) columns x rows in size (1 degree by 1 degree) and have its origin exactly on a a longitude, latitude boundary (i.e 133, 45 not 130.2, 45.6)

However, after seeing your edit with gdalinfo output, I will say that you won't be able to convert your data to HGT.

Well you can, but it will be useless.

The smallest cellsize supported by the HGT driver is 0.0002777777° (~30m) and your data is 2m. You'd need to resample to 30m pixels... Are you sure you need to convert from a standard GeoTIFF format to an unusual format which was designed for a very specific dataset (SRTM) not for general DEMs?

Related Question