GeoEra-GIP / Project-Support-WP8

Science Project Data provider support
https://geoera-gip.github.io/support/
7 stars 2 forks source link

Mapserver Style #569

Closed caasox closed 2 years ago

caasox commented 2 years ago

Dear support-team,

I'm trying to create a colorramp for a raster dataset. However if do something like this:

CLASS
   EXPRESSION([pixel] >= -1617 AND [pixel] <= 18)
   STYLE
     COLORRANGE 0 0 255 255 255 0 #color start RGB and end RGB
     DATARANGE -1617 -800
   END #STYLE
   STYLE
     COLORRANGE 255 255 0 255 0 0 #color start RGB and end RGB
     DATARANGE -800 18
   END #STYLE
 END #class

only the first colour range is visible the second one is ignored. What am I doing wrong?

Best regards

nmtoken commented 2 years ago

I think if you use EXPRESSION you need separate classes, what if you just use:

CLASS
    STYLE
        COLORRANGE 0 0 255 255 255 0 #color start RGB and end RGB
        DATARANGE -1617 -800
    END #STYLE
    STYLE
        COLORRANGE 255 255 0 255 0 0 #color start RGB and end RGB
        DATARANGE -800 18
    END #STYLE
END #class
caasox commented 2 years ago

@nmtoken Well still not as expected. Now everything is yellow. No color ramp at all.

nmtoken commented 2 years ago

What if you try with expressions like:

CLASS
    EXPRESSION ([pixel] >= -1617 AND [pixel] <= 800)
    STYLE
        COLORRANGE 0 0 255 255 255 0 #color start RGB and end RGB
    END #STYLE
END
CLASS
    EXPRESSION ([pixel] > 800 AND [pixel] <= 18)
    STYLE
        COLORRANGE 255 255 0 255 0 0 #color start RGB and end RGB
    END #STYLE
END #class
caasox commented 2 years ago

Now the first range is shown, but the second one is ignored.

nmtoken commented 2 years ago

The following syntax works for me in MapServer, (not tested on the EGDI platform)

    CLASS
        # ref: https://github.com/mapserver/mapserver/wiki/Color-Ramps
        EXPRESSION ([pixel] >= 0 AND [pixel] < 15)
        STYLE
            COLORRANGE  "#0000ff" "#ffff00"  # blue to yellow
            # The data range is normally set to the class expression range
            #DATARANGE 5 15
            DATARANGE 0 15
            RANGEITEM "pixel"
        END
    END
    CLASS
        EXPRESSION ([pixel] >= 15 AND [pixel] < 748)
        STYLE
            COLORRANGE "#ffff00" "#ff0000" # yellow to red
            DATARANGE 15 40
            RANGEITEM "pixel"
        END
    END

Gives

image

Something to be aware of is is the range of your data values, if most your data is skewed to one end, then you'll see only one end of the colorrange.

So same data , expressions, colorranges but one different datarange

    CLASS
        # ref: https://github.com/mapserver/mapserver/wiki/Color-Ramps
        EXPRESSION ([pixel] >= 0 AND [pixel] < 15)
        STYLE
            COLORRANGE  "#0000ff" "#ffff00"  # blue to yellow
            # The data range is normally set to the class expression range
            #DATARANGE 5 15
            DATARANGE 0 15
            RANGEITEM "pixel"
        END
    END
    CLASS
        EXPRESSION ([pixel] >= 15 AND [pixel] < 748)
        STYLE
            COLORRANGE "#ffff00" "#ff0000" # yellow to red
            # Most data is below 40
            DATARANGE 15 748
            RANGEITEM "pixel"
        END
    END

Gives:

image

caasox commented 2 years ago

@nmtoken once again that solved the problem. Thank you!