2

I have (for example) SRTM-1 file n48e083.hgt with resolution 3601x3601.

What is right way to convert it to GeoTIFF?

gdal_translate -srcwin 0 0 3600 3600 -a_ullr 83 49 84 48 n48e083.hgt n48e083.tif

or

gdalwarp -te 83 48 84 49 -ts 3600 3600 n48e083.hgt n48e083.tif

I suppose the first is right and faster but I have some doubts.

And second question. I wonder why gdal_translate does not copy "Unit Type" metadata value from hgt to tiff but gdal_merge does in the examples above?

UPDATE 1: gdalinfo n48e083.hgt

Driver: SRTMHGT/SRTMHGT File Format
Files: n48e083.hgt
Size is 3601, 3601
Coordinate System is:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (82.999861111111116,49.000138888888891)
Pixel Size = (0.000277777777778,-0.000277777777778)
Metadata:
  AREA_OR_POINT=Point
Corner Coordinates:
Upper Left  (  82.9998611,  49.0001389) ( 82d59'59.50"E, 49d 0' 0.50"N)
Lower Left  (  82.9998611,  47.9998611) ( 82d59'59.50"E, 47d59'59.50"N)
Upper Right (  84.0001389,  49.0001389) ( 84d 0' 0.50"E, 49d 0' 0.50"N)
Lower Right (  84.0001389,  47.9998611) ( 84d 0' 0.50"E, 47d59'59.50"N)
Center      (  83.5000000,  48.5000000) ( 83d30' 0.00"E, 48d30' 0.00"N)
Band 1 Block=3601x1 Type=Int16, ColorInterp=Undefined
  NoData Value=-32768
  Unit Type: m

UPDATE 2:

gdalwarp with "-r cubic" option:

gdalwarp -te 83 48 84 49 -ts 3600 3600 -r cubic n48e083.hgt n48e083.tif

makes tiff file which appears to be visually identical to original hgt when I compare them in QGIS.

First two methods I mentioned make TIFF files which has very light visual shift (~0.5 pixel).

Alexey Gusev
  • 21
  • 1
  • 4
  • What does gdalinfo n48e083.hgt report about the coordinate system and extents? – user30184 Jan 31 '21 at 19:43
  • 1
    I've updated my question with that information. – Alexey Gusev Jan 31 '21 at 20:18
  • 1
    Minimum that should work is simply gdal_translate n48e083.hgt n48e083.tif. GDAL knows the extents and decides what is suitable output size. But if it is important for you to have just 3600x3600 then using -ts is ok. The shift may be caused by the image type AREA_OR_POINT=Point which makes you manually given extents wrong by half a pixel. – user30184 Jan 31 '21 at 21:24

0 Answers0