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

Trygve Aspenes trygve at aspenes.priv.no
Tue Aug 29 01:35:07 PDT 2023



Yeah I also saw that. So I guess value_<band number 0 based> should do 
it.

I'm working with netcdf so I wondered if that has something to do with 
it. So I tried with a geotiff. Also not working. Then I updated my 
mapserver to 8.0.1 from 7.4 something, and now I get the expected style 
for both geotiff and netcdf.

So version do matter!

Thank you for your patience Seth!

Trygve Aspenes

Den 2023-08-28 16:07, skrev Seth G:
> A good question and it doesn't seem to be clearly documented.
> I've always tried values listed at 
> https://mapserver.org/el/input/raster.html#raster-query even though 
> that section appears to be written for MapScript.
> Each band has a value based on index, so you should get results using 
> "value_0", "value_1", and "value_2" in RANGEITEM.
> gdalinfo should peobably provide details on the value ranges in each 
> band.
> 
> Seth
> 
> --
> web:https://geographika.net & https://mapserverstudio.net
> twitter: @geographika
> 
> On Mon, Aug 28, 2023, at 2:50 PM, Trygve Aspenes via MapServer-users 
> wrote:
>> 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
>> _______________________________________________
>> 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