1

My problem is that I'm trying to extract contours and elevations from a DEM map. Everything else looks fine, but I think that the "ELEV" values I'm getting are not the real elevations, maybe I'm missing something. The steps that I follow are:

  1. Import WMS DEM map to my project
  2. Run the map to raster algorithm - [Settings: Map units per pixel: 1 (I'm doing tests with small areas) / make the background transparent / unique layer to render: the WMS DEM layer)
  3. With the output I get from the first step, I run the "Contour" algorithm with the following settings: Band(Red) / Interval between contour: 1 (here I always use the same value as the "map units per pixel" value, correct me if I'm doing it wrong)
  4. And that's it, the last thing I do is add the single labels that show the "ELEV" values of the contours.
8
  • Are you having your contours created by a WMS layer or are you importing a raster saved in your PC?
    – Val P
    Apr 27 '20 at 16:15
  • I import a DEM layer from WMS and then I create the contours with the "contours" process
    – Satcar
    Apr 27 '20 at 16:31
  • I am trying to replicate your process and it works fine with me. Which version of QGIS are you using? Can you share projection and WMS?
    – Val P
    Apr 27 '20 at 16:59
  • Does the red band has slevetion values or image/pixel values? Apr 27 '20 at 19:01
  • 1
    You get probably RGB images with 8 bits per band from WMS. So the data range of the red band is 0-255. Are you sure that you are now dealing with a real DEM and not with an image that is generated from DEM for visualizing purposes? I guess that the original DEM is of 32 bit float type.
    – user30184
    Apr 28 '20 at 6:39
0

Here is an URL that saves some data from the DEM layer into a tiff file. I selected tiff because I guessed that it migh deliver data with higher bit depth than 8 bit per band. The attached gdalinfo report shows that it is not the case. What you are getting from the service with GetMap is just an image of the DEM but it does not contain real DEM data.

curl "http://geoserveis.icgc.cat/icgc_mdt2m/wms/service?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&WIDTH=1601&HEIGHT=835&LAYERS=MET2m&TRANSPARENT=TRUE&FORMAT=image%2Ftiff&BBOX=41.73789833892216,1.1666825875312856,42.01488889221557,1.6977746543848833&CRS=EPSG:4230&STYLES=" -o dem.tif



gdalinfo dem.tif -stats
Driver: GTiff/GeoTIFF
Files: dem.tif
Size is 1601, 835
Metadata:
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_XRESOLUTION=96
  TIFFTAG_YRESOLUTION=96
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  835.0)
Upper Right ( 1601.0,    0.0)
Lower Right ( 1601.0,  835.0)
Center      (  800.5,  417.5)
Band 1 Block=1601x8 Type=Byte, ColorInterp=Red
  Minimum=52.000, Maximum=147.000, Mean=92.948, StdDev=19.269
  Metadata:
    STATISTICS_MAXIMUM=147
    STATISTICS_MEAN=92.947795352456
    STATISTICS_MINIMUM=52
    STATISTICS_STDDEV=19.269070509899
    STATISTICS_VALID_PERCENT=100
Band 2 Block=1601x8 Type=Byte, ColorInterp=Green
  Minimum=52.000, Maximum=147.000, Mean=92.948, StdDev=19.269
  Metadata:
    STATISTICS_MAXIMUM=147
    STATISTICS_MEAN=92.947795352456
    STATISTICS_MINIMUM=52
    STATISTICS_STDDEV=19.269070509899
    STATISTICS_VALID_PERCENT=100
Band 3 Block=1601x8 Type=Byte, ColorInterp=Blue
  Minimum=52.000, Maximum=147.000, Mean=92.948, StdDev=19.269
  Metadata:
    STATISTICS_MAXIMUM=147
    STATISTICS_MEAN=92.947795352456
    STATISTICS_MINIMUM=52
    STATISTICS_STDDEV=19.269070509899
    STATISTICS_VALID_PERCENT=100

Thus band 1 is 8 bit, the available data range is 0-255 and image is actually using range 52-147. If you have only this image it is impossible to convert the pixel values with corresponding terrain heights.

The WMS service seems to support also GetFeatureInfo request that returns the following data from a clicked point:

Stretchedvalue PixelValue;
59             543.890015; 

Here the PixelValue is probably the pixel value in the source DEM and StretchedValue how it is mapped into the 0-255 range of the WMS GetMap output. PixelValue may well tell the height directly: 543.89 meters. Unfortunately there is no way for getting the mapping between values of the source pixels and GetMap pixels from WMS server.

If nothing else exist and you are in an ultimage trouble you could make such look-up table be clicking around the map with GetFeatureInfo and writing the results into spreadsheet but still the resolution of an 8 bit image is pretty poor for a DEM. You do not have good chance for creating contours with accurate height values if you base your work on this WMS service.

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.