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

Trygve Aspenes trygve at aspenes.priv.no
Mon Aug 28 05:50:37 PDT 2023


Thanks Seth for your quick reply

Yes I have multiple bands. gdalinfo tells me I have bands like this:
Band 1 Block=949x1069 Type=Float32, ColorInterp=Undefined
Band 2 Block=949x1069 Type=Float32, ColorInterp=Undefined
Band 3 Block=949x1069 Type=Float32, ColorInterp=Undefined
.
.
.
Band n Block=949x1069 Type=Float32, ColorInterp=Undefined

So, how could I figure out how the various bands are named in mapserver 
for the RANGEITEM?

I have looked at the documentation for STYLE/RANGEITEM but I still don't 
get it.

I have tried various values for RANGEITEM ( like "value_0", "0", "1", 
"pixel", "Band 1" etc), but I dont get it.

It must be something that I'm missing.

By the way, thanks for the mapserverstudio link. Most helpful!
Trygve Aspenes


Den 2023-08-28 13:14, skrev Seth G:
> 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