1

I have encoded some metrics in a 4-band geotiff that will be served by MapServer (v7.4), and I want to "decode" them client-side for display using raster operations in OpenLayers (v6.1). (This is something somewhat similar to what is done in this openlayers workshop.)

The problem is that my metrics values range from 1 to 156 (and I used 255 for nodata), and MapServer scale them to 0-254 during rendering for better display, so the client do not have access to the original metrics.

I would need the client to have access to the original values. I have tried adding the following directives to the mapfile layer definition, but to no avail. 'PROCESSING "LUT=1:1,156:156"' or 'PROCESSING "SCALE=0,254"'

Here is the layer definition:

LAYER
    NAME tif_source
    STATUS ON
    TYPE RASTER
    DATA "/test.tif"
    PROJECTION
        "init=epsg:32198"
    END

    METADATA
        wms_enable_request "*"
        wms_title "tif_source"
    END

    # PROCESSING "SCALE_1=0,254"  ## does not produce the expected result
    # PROCESSING "LUT=1:1,156:156" ## does not work either
    PROCESSING "LOAD_FULL_RES_IMAGE=YES"

    DEBUG 4
END

How should I prevent MapServer from scaling the raster values during rendering?

  • No automatic scaling should happen. What is your outputformat and do you have special settings for that format? How do you exactly handle 4-band input? Do you select the three bands for RGB with processing directive? – user30184 Jun 23 at 16:02
  • Make sure it is not a client issue. Be sure to set context.imageSmoothingEnabled = false as in openlayers.org/en/main/examples/sea-level.html – Mike Jun 23 at 16:23
  • No special directive for the format, png (AGG/PNG) is used with its default values. No special directive either for the bands, they seem to be picked correctly. From the debug logs: "msDrawRasterLayerGDAL(): red,green,blue,alpha bands = 1,2,3,4" – Frederic Jun 23 at 17:53
1

If you want to use data from a W*S then you should be using a WCS not a WMS. a WMS returns a picture of the data while a WCS returns the actual raster data.

MapServer supports WCS so it should be easy.

| improve this answer | |
  • That is true, but if input images are 8-bit with one or three bands it should possible, if not the default, to keep pixel values unchanged. Despite the effect of resampling, naturally. – user30184 Jun 23 at 16:06
  • No guarantee of any thing in a WMS just don't do it – Ian Turton Jun 23 at 17:42

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.