Parallel to gdalwarp `-te -5.8 41 10 51.5 -ts 1980 0` not working with mercator? , my hillshade works with lat/long input :

gdaldem hillshade input.tmp.tif shadedrelief.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges

But stopped to work when input is in mercator :

gdalwarp -of GTiff -s_srs EPSG:4326 -t_srs EPSG:3857  input.tmp.tif reproj.tmp.tif #mercator
gdaldem hillshade reproj.tmp.tif shadedrelief.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges

While lat/long is in degree, mercator is in meters, I believe both z scales to be in m which requires -s 111120 (requires -s 370400 if in feet!). Also, what do I do wrong ?

  • 2
    Simple, remove the -s scale option for projected rasters. – Mike T Mar 1 '15 at 23:01
  • Works... But Why? why, why..... <coding> – Hugolpz Mar 1 '15 at 23:10
  • Seems mercator need -s 1, equal to no -s. – Hugolpz Mar 1 '15 at 23:11

The scale option is only needed for "unprojected" rasters with units in degrees. It is the ratio of height units used in the DEM (typically meters) to distance units in degrees.

So for Mercator or other projected rasters, you can ignore the scale option, or use the default of 1 (no scale).

  • So, as a good practice, should I always reproject my source ? and will it change to meters if I reproject from lat/lon to lat/long. (your are not required to answer that but if you know it's a good add) – Hugolpz Mar 1 '15 at 23:09
  • It really depends on what you are doing with the data. I generally keep the originals, e.g. SRTM data are lat/long. – Mike T Mar 1 '15 at 23:12
  • Yeah, I use SRTM to do this (work in progress, hillshade coming within minutes :) ), all done via make script. Point is, as I don't want to balance between -s 111120 and -s 1, if I can have a trick to always have my input in meters it would ease my use case. – Hugolpz Mar 1 '15 at 23:15
  • The scale option is needed if vertical and horizontal units are different. Most usual case is just the degrees/meters case but other combinations are possible as well, like feet/meters. – user30184 Mar 2 '15 at 7:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.