0

I've created RasterSymbolizer-based styles (colour ramps )for a bunch of trend maps layers (from NetCDFs) in GeoServer, and I serve them over WMS. I also have matching p-value raster layers, and I'd like to fill the parts of those layers with a hatching pattern, rather than a solid fill (because I want to overlay the statistical significance on the trend layer as a layer group).

I understand that hatching fill is not available with the RasterSymbolizer, but it is doable with a PolygonSymbolizer. According to the YSLD reference http://docs.geoserver.org/stable/en/user/styling/ysld/reference/symbolizers/index.html;, the latter can actually be applied to a raster. Sure enough, when I create a PolygonSymbolizer style and preview the p-value, I get a big, green square the size of the map.

But if I try to add a Filter, things stop working. The style validates, btu the Layer Preview no longer works properly. Here's what I'm trying:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/sld
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd";
  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">;

  <NamedLayer>
    <Name>Statistically significant trend (p lt 0.05)</Name>
    <UserStyle>
      <Title>Statistically significant trend (p lt 0.05)</Title>
      <FeatureTypeStyle>
        <Rule>
          <Name>Stat. sig. (p &lt; 0.05)</Name>
          <ogc:Filter>
            <ogc:PropertyIsLessThanOrEqualTo>
              <ogc:PropertyName>quantity</ogc:PropertyName>
              <ogc:Literal>0.05</ogc:Literal>
            </ogc:PropertyIsLessThanOrEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#D3FFD3</CssParameter>
              <CssParameter name="fill-opacity">0.5</CssParameter>
            </Fill>
            <Stroke>
              <CssParameter name="stroke">#6DB26D</CssParameter>
            </Stroke>
          </PolygonSymbolizer>
        </Rule>

      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

One problem could be the PropertyName value: I'm not sure whether to just use 'quantity', or the band name (which is 'pvalue' for all of the layers I want to use this style with) or the layer name (which varies). None of these work. Or maybe the Filter is incompatible with raster layers (even when they're using PolygonSymbolizer)? I'm not sure.

If someone can help me with this (or an alternate way to get hatch fills over parts of a raster layer), that'd be fantastic :)

1

A polygon symbolizer applied on a raster does just that, takes the bbox of the raster and treats it as a polygon. No filtering is possible.

If you want to treat your raster as set of filterable polygons, make it into polygons using a rendering transformation instead, see a SLD example here:

https://geoserver.geo-solutions.it/edu/en/wps/rendering_tx.html#contour-extraction-styled-as-polygons

  • Ah, I wondered if that might be the case. Thanks—I'll give the rendering transformation a go in a couple of days! – rensa May 12 '18 at 9:12
  • I haven't quite been able to get there yet—I'm trying to follow the PolygonExtraction example with a single range of [0;0.05], but the error I'm getting in the logs when I try to request the layer is: Caused by: java.security.InvalidParameterException: Could not convert the value [0;0.05] into the expected type class org.jaitools.numeric.Range for parameter ranges. I'm wondering if I need to escape something here? – rensa May 14 '18 at 2:50

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.