3

Is it possible to scale or offset raster layers in GeoServer SLD, for example to convert Kelvin to Celsius on the fly?

Given a basic raster style:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name>sample_raster</Name>
    <UserStyle>
      <Title>Sample Raster</Title>
      <FeatureTypeStyle>
        <Rule>
          <RasterSymbolizer>
            <ColorMap>
              <ColorMapEntry color="#000000" quantity="0"  label="values"/>
              <ColorMapEntry color="#FFFFFF" quantity="20"  label="values"/>
            </ColorMap>
          </RasterSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

presumably something like

<ogc:Add>
    <ogc:Function name="parameter">
        <ogc:Literal>data</ogc:Literal>
    </ogc:Function>
    <ogc:Literal>-273.15</ogc:Literal>
</ogc:Add>

needs to be incorporated somewhere, but I can't for the life of me figure out how to include this correctly.

  • I have same issue. If data is stored in degrees Kelvin and my output will be in Celsius... How do I configure/setup GeoServer to serve the same data without any modification? Thx – user64022 Dec 16 '15 at 19:14
1

Short answer, you can't.

Longer answer, it would not be too hard to code a rendering transformation to do that as part of styling. Probably a day of work not more. All the machinery is in place, there is already a rescale coverage operation in GeoTools that you can hook as a raster rendering transformation.

Simone.

3

Update 6/2018:

In case someone finds this later. This problem can currently be easily solved using Jiffle scripting language as a rendering transformation in development build of Geoserver with WPS processing plugin installed.

Sample code:

<Transformation>
  <ogc:Function name="ras:Jiffle">
    <ogc:Function name="parameter">
      <ogc:Literal>coverage</ogc:Literal>
    </ogc:Function>
    <ogc:Function name="parameter">
      <ogc:Literal>script</ogc:Literal>
      <ogc:Literal>
        temp = src[0];
        subt = 273.15;
        dest = temp - subt;
      </ogc:Literal>
    </ogc:Function>
  </ogc:Function>
</Transformation>

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.