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">
      <Title>Sample Raster</Title>
              <ColorMapEntry color="#000000" quantity="0"  label="values"/>
              <ColorMapEntry color="#FFFFFF" quantity="20"  label="values"/>

presumably something like

    <ogc:Function name="parameter">

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

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.



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:

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

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.