after inspecting the gdalinfo of my input file :

Driver: GTiff/GeoTIFF
Files: elevation.tif
Size is 5555, 2525
Coordinate System is:
        SPHEROID["WGS 84",6378137,298.257223563,
Origin = (-1.630972222222222,35.957916666666655)
Pixel Size = (0.000277777777778,-0.000277777777778)
Image Structure Metadata:
Corner Coordinates:
Upper Left  (  -1.6309722,  35.9579167) (  1d37'51.50"W, 35d57'28.50"N)
Lower Left  (  -1.6309722,  35.2565278) (  1d37'51.50"W, 35d15'23.50"N)
Upper Right (  -0.0879167,  35.9579167) (  0d 5'16.50"W, 35d57'28.50"N)
Lower Right (  -0.0879167,  35.2565278) (  0d 5'16.50"W, 35d15'23.50"N)
Center      (  -0.8594444,  35.6072222) (  0d51'34.00"W, 35d36'26.00"N)
Band 1 Block=5555x1 Type=Int16, ColorInterp=Gray

my guess was that this is because the unit are in degrees so 0.0002 give black or something like...

so i have tried to reproject to utm with

gdalwarp -t_srs "+proj=utm +datum=WGS84+zone=30+units=meter" elevation.tif elevationutm.tif

but gave me an error

ERROR 1: Too many points (2704 out of 2704) failed to transform, unable to compute output bounds.

also i have played a little with gdal_translate with the scale parameter

gdal_translate -scale 0 1 0 100 -of png -ot Uint16 elevation.tif elevation.png

wich gave me something that looks good, but here the 100 value parameter are completly based on some random tests, so my question :

how to scale properly my dem to get the correct png output ?

I want to use these stuff in a terrain 3d engine that take a png Uint16 or raw Int16 as an input.

  • Do gdalinfo elevation.tif -hist for computing the histogram of the source image. Then you do not need to guess the values for -scale. – user30184 Apr 5 '17 at 19:12
  • I do not believe that the unit of altitude is degrees in your input data. Have a look at the real pixel values. I guess that you'll see that they rather present meters, centimeters, or feet. Uint16 has a wide data range and world is rather flat so altitudes may all be near the lower end of the scale. Tell your 3d engine what the unit is and if it is a good 3d engine it will handle the rest. – user30184 Apr 5 '17 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.