mapboxrgbgeoserverterrainsld

How to use geoserver SLD style to serve single channel elevation raster ("gray" channel) as Mapbox Terrain-RGB tiles


I have an elevation raster layer in my GeoServer with a single channel ("gray"). The "gray" values is elevations values (signed int16). I have 2 clients:

  1. The first one is using that elevation values as is.
  2. The second one expect to get [Mapbox Terrain-RGB format][1]

I do not want to convert the "gray scale" format to Mapbox Terrain-RGB format and hold duplicate data in the GeoServer. I was thinking to use the SLD style and elements to map the elevation value to the appropriate RGB value (with gradient interpolation between discrete values). For example:

          <ColorMap>
            <ColorMapEntry color="#000000" quantity="-10000" />
            <ColorMapEntry color="#FFFFFF" quantity="1667721.5" />
          </ColorMap>

It turns out that the above example does not span the full range of colors but rather creates gray values only. That is, it seems that it interpolate each color (red, green, blue) independent of each other.

Any idea how to make it interpolate values like that: #000000, #000001, #000002, ... , #0000FF, #000100, ..., #0001FF, ..., #FFFFFF?

Tx. [1]: https://docs.mapbox.com/data/tilesets/reference/mapbox-terrain-rgb-v1/


Solution

  • I'm trying to do the same with no luck, and i think it can't be done... Check this example. It's a "gradient" [-10000, -5000, -1000, -500 ... 100000000000000000, 5000000000000000000, 1000000000000000000] with the Mapbox color codification. The color progression/interpolation is anything but linear, so i think it can't be emulated in an SLD.