[MapServer-users] mapserver: styling multiple stop colorrange for raster data

Seth G sethg at geographika.co.uk
Mon Aug 28 04:14:03 PDT 2023


Hi Trygve,

You can have multiple start/stop values and your syntax looks correct. Maybe you have multiple bands in your raster and you are symbolising on the incorrect value? Try explicitly setting the RANGEITEM. 

See working example at https://app.mapserverstudio.net/#9JBVADFh

        CLASS
            NAME "colorramp"
            STYLE
                COLORRANGE "#e3edfc" "#287593" # a color gradient from light grey to a shade of blue
                # a pixel value of -20 will be light grey, and values from -20 to 0 will be 
                # assigned a color from the colour gradient of light grey to blue
                DATARANGE -20 0
                RANGEITEM "value_0" # this is the name of the value band in the raster, the datasets used in the Mapfile have a single band
            END
            STYLE
                COLORRANGE "#29497b" "#759387"
                DATARANGE 0 20
                RANGEITEM "value_0"
            END
            STYLE
                COLORRANGE "#bfa96d" "#480d26"
                DATARANGE 20 50
                RANGEITEM "value_0"
            END
        END

Seth


--
web:https://geographika.net & https://mapserverstudio.net
twitter: @geographika

On Mon, Aug 28, 2023, at 12:06 PM, Trygve Aspenes via MapServer-users wrote:
> Hi all
>
> I'm looking into creating a styling for a raster of float32 data.
> The data describes temperature in kelvin and I want to have a colorrange 
> from blue to white for data up to 273 deg kelvin(0 deg C). And from 
> white to red for warmer data.
>
> I see here 
> https://mapserver.org/output/kerneldensity.html#raster-color-ramping how 
> this is used for heatmap hoping that this will work for a raster also.
>
> I try with something like this:
>
>      CLASS
>        STYLE
>          COLORRANGE "#0000ffff" "#ffffffff"
>          DATARANGE 200 273
>        END # STYLE
>        STYLE
>          COLORRANGE "#ffffffff" "#ff0000ff"
>          DATARANGE 273 315
>        END # STYLE
>      END # CLASS
>
> but as far as I can see this gives me only white.
>
> If I try to use one style like this:
>
>      CLASS
>        STYLE
>          COLORRANGE "#0000ffff" "#ff0000ff"
>          DATARANGE 200 315
>        END # STYLE
>      END # CLASS
>
> it works but the color range goes directly from red to blue.
>
> Am I doing something wrong or can I not use multiple stops for these 
> kind of data?
>
> Trygve Aspenes
> _______________________________________________
> MapServer-users mailing list
> MapServer-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the MapServer-users mailing list