1

I have some GeoTIFFs with elevation data, displayed in OpenLayers or Leaflet via WMS from MapServer. I need to be able to request (from the client) the elevation at some point clicked by the user.

Does MapServer provide this functionality? If yes, how? If no, do you know a way to do so?

  • It is doable through GetFeatureInfo. – user30184 Oct 21 '15 at 10:58
  • Thanks, but can you elaborate a little bit? I'm playing with MapServer templates, but I don't know how to get the elevation data... – Tim Autin Oct 21 '15 at 13:32
0

This might be all that you need to do, please test.

  1. Create a query template file. For this purpose it can be a dummy "template.html" with just one row with the magic string

<!-- MapServer Template -->

  1. Make the raster layer queryable by adding into MAP - LAYER

TEMPLATE "/path/to/template.html"

  1. By default no data is selected, add all data through adding into MAP - LAYER - METADATA

"wms_include_items" "all"

Now it should work with text/plain info_format. Test first by reading the GetCapabilities which must show for your raster layer

<Layer queryable="1"

If that is the case you can test with QGIS by adding WMS layer, selecting the layer from Table of contents and by using the feature info tool. The info format must be text/plain. Text/html needs couple of further steps: a real template https://github.com/mapserver/mapserver/wiki/RasterQuery and adding a new info format into MAP - WEB:

"wms_feature_info_mime_type" "text/html"

  • Thanks. I'm getting the following attributes : x, y, value_0, value_list, red, green and blue. value_0, value_list, red, green and blue have the same value, but not what I'm expecting (189 when I'm expecting an elevation of -1600). Is this the elevation stored in my data? – Tim Autin Oct 21 '15 at 14:26
  • OK sorry, I was using the wrong GeoTIFF ><... It works thanks a lot! – Tim Autin Oct 21 '15 at 14:30
  • Great. GetFeatureInfo in MapServer is complicated and documentation does not shine. – user30184 Oct 21 '15 at 14:36
  • To be fair, the problem was mostly that I'm totally new with GeoTIFFs ^^ – Tim Autin Oct 21 '15 at 14:38

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.