1

I am trying to make a map with PostGIS and GeoServer, showing weather data. The data that I have is pointdata from observation stations.

The data is vectordata. With an SLD using the Barnes Surface rendering transformation I get the following WMS output (OpenLayers preview): enter image description here

Now i want to add contour lines. Of course that is a Raster-to-Vector rendering transformation. I read that it should be possible to use the Barnes Surface transformation as input for my contour transformation. But I cannot find how to do this. There is very little documentation about this.

I only found this question: Chaining Rendering Transformations: Making isotherms using Barnes Surface + Contour process?, but the site that is referenced is not even online anymore and there is not really a clear answer.

The SLD documentation says that it is possible to use multiple rendering transformations, but I do not know how to code it. Can anybody help with that? What am I doing wrong?

Below the SLD code that I am working with now:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
 xsi:schemaLocation="http://www.opengis.net/sld 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> BarnesContours </Name> 
        <UserStyle> 
        <Title> Barnes Surface Contours </Title> 
        <Abstract> Extracts from a computed surface </Abstract> 
  <FeatureTypeStyle> 
   <Transformation>
     <ogc:Function name="vec:BarnesSurface">
       <ogc:Function name="parameter">
         <ogc:Literal>data</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>valueAttr</ogc:Literal>
         <ogc:Literal>ff</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>scale</ogc:Literal>
         <ogc:Literal>15.0</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>convergence</ogc:Literal>
         <ogc:Literal>0.2</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>passes</ogc:Literal>
         <ogc:Literal>3</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>minObservations</ogc:Literal>
         <ogc:Literal>1</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>maxObservationDistance</ogc:Literal>
         <ogc:Literal>10</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>pixelsPerCell</ogc:Literal>
         <ogc:Literal>10</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>queryBuffer</ogc:Literal>
         <ogc:Literal>40</ogc:Literal>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>outputBBOX</ogc:Literal>
         <ogc:Function name="env">
            <ogc:Literal>wms_bbox</ogc:Literal>
         </ogc:Function>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>outputWidth</ogc:Literal>
         <ogc:Function name="env">
            <ogc:Literal>wms_width</ogc:Literal>
         </ogc:Function>
       </ogc:Function>
       <ogc:Function name="parameter">
         <ogc:Literal>outputHeight</ogc:Literal>
         <ogc:Function name="env">
            <ogc:Literal>wms_height</ogc:Literal>
         </ogc:Function>
       </ogc:Function>
     </ogc:Function>
   </Transformation>
   <Rule>
     <RasterSymbolizer>
       <!-- specify geometry attribute of input to pass validation -->
       <Geometry><ogc:PropertyName>point</ogc:PropertyName></Geometry>
       <Opacity>0.8</Opacity>
       <ColorMap type="ramp" >
         <ColorMapEntry color="#FFFFFF" quantity="-990" label="nodata" opacity="0"/>
         <ColorMapEntry color="#2E4AC9" quantity="-9" label="values"/>
         <ColorMapEntry color="#41A0FC" quantity="-6" label="values" />
         <ColorMapEntry color="#58CCFB" quantity="-3" label="values" />
         <ColorMapEntry color="#76F9FC" quantity="0" label="values" />
         <ColorMapEntry color="#6AC597" quantity="2" label="values" />
         <ColorMapEntry color="#479364" quantity="4" label="values" />
         <ColorMapEntry color="#2E6000" quantity="6" label="values" />
         <ColorMapEntry color="#579102" quantity="8" label="values" />
         <ColorMapEntry color="#9AF20C" quantity="10" label="values" />
         <ColorMapEntry color="#B7F318" quantity="12" label="values" />
         <ColorMapEntry color="#DBF525" quantity="14" label="values" />
         <ColorMapEntry color="#FAF833" quantity="16" label="values" />
         <ColorMapEntry color="#F9C933" quantity="18" label="values" />
         <ColorMapEntry color="#F19C33" quantity="20" label="values" />
         <ColorMapEntry color="#ED7233" quantity="22" label="values" />
         <ColorMapEntry color="#EA3F33" quantity="24" label="values" />
         <ColorMapEntry color="#BB3026" quantity="40" label="values" />
       </ColorMap>
       </RasterSymbolizer>
    </Rule>
   </FeatureTypeStyle>
   <FeatureTypeStyle>
     <Transformation>
            <ogc:Function name="ras:Contour">
              <ogc:Function name="parameter">
                <ogc:Literal>data</ogc:Literal>
              </ogc:Function>
              <ogc:Function name="parameter">
                <ogc:Literal>ff</ogc:Literal>
                <ogc:Literal>-5</ogc:Literal>
                <ogc:Literal>0</ogc:Literal>
                <ogc:Literal>5</ogc:Literal>
                <ogc:Literal>10</ogc:Literal>
                <ogc:Literal>15</ogc:Literal>
                <ogc:Literal>20</ogc:Literal>
                <ogc:Literal>25</ogc:Literal>
                <ogc:Literal>30</ogc:Literal>
              </ogc:Function>
            </ogc:Function>
     </Transformation>
     <Rule>
       <Name>rule1</Name>
       <Title>Contour Line</Title>
       <LineSymbolizer>
         <Stroke>
           <CssParameter name="stroke">#000000</CssParameter>
           <CssParameter name="stroke-width">1</CssParameter>
         </Stroke>
       </LineSymbolizer>
       <TextSymbolizer>
         <Label>
           <ogc:PropertyName>value</ogc:PropertyName>
         </Label>
         <Font>
           <CssParameter name="font-family">Arial</CssParameter>
           <CssParameter name="font-style">Normal</CssParameter>
           <CssParameter name="font-size">10</CssParameter>
         </Font>
         <LabelPlacement>
           <LinePlacement/>
         </LabelPlacement>
         <Halo>
           <Radius>
             <ogc:Literal>2</ogc:Literal>
           </Radius>
           <Fill>
             <CssParameter name="fill">#FFFFFF</CssParameter>
             <CssParameter name="fill-opacity">0.6</CssParameter>
           </Fill>
         </Halo>
         <Fill>
           <CssParameter name="fill">#000000</CssParameter>
         </Fill>
         <Priority>2000</Priority>
         <VendorOption name="followLine">true</VendorOption>
         <VendorOption name="repeat">100</VendorOption>
         <VendorOption name="maxDisplacement">50</VendorOption>
         <VendorOption name="maxAngleDelta">30</VendorOption>
       </TextSymbolizer>
     </Rule>
   </FeatureTypeStyle>
   </UserStyle>
 </NamedLayer>
</StyledLayerDescriptor>

The first part of the code works! The result of that is the image shown above. But the second part, the contour part, is not working. If I try to preview it on the layer I get the following message: enter image description here

I think the way I am doing this is wrong, but there is not really a good example online that shows how it should be done. Or at least I have not found that yet..

1 Answer 1

1

You can read this tutorial describing the approach.

The issue is with the contour section. As it is, the original point data is used. Instead, you would need to give it the Barne Surface output. To do so, within the countour data section, re-compute the Barne Surface

<Transformation>
    <ogc:Function name="ras:Contour">
      <ogc:Function name="parameter">
        <ogc:Literal>data</ogc:Literal>

            <ogc:Function name="vec:BarnesSurface">
                   <ogc:Function name="parameter">
                     <ogc:Literal>data</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>valueAttr</ogc:Literal>
                     <ogc:Literal>ff</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>scale</ogc:Literal>
                     <ogc:Literal>15.0</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>convergence</ogc:Literal>
                     <ogc:Literal>0.2</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>passes</ogc:Literal>
                     <ogc:Literal>3</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>minObservations</ogc:Literal>
                     <ogc:Literal>1</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>maxObservationDistance</ogc:Literal>
                     <ogc:Literal>10</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>pixelsPerCell</ogc:Literal>
                     <ogc:Literal>10</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>queryBuffer</ogc:Literal>
                     <ogc:Literal>40</ogc:Literal>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>outputBBOX</ogc:Literal>
                     <ogc:Function name="env">
                        <ogc:Literal>wms_bbox</ogc:Literal>
                     </ogc:Function>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>outputWidth</ogc:Literal>
                     <ogc:Function name="env">
                        <ogc:Literal>wms_width</ogc:Literal>
                     </ogc:Function>
                   </ogc:Function>
                   <ogc:Function name="parameter">
                     <ogc:Literal>outputHeight</ogc:Literal>
                     <ogc:Function name="env">
                        <ogc:Literal>wms_height</ogc:Literal>
                     </ogc:Function>
                   </ogc:Function>
                 </ogc:Function>

      </ogc:Function>
      <ogc:Function name="parameter">
        <ogc:Literal>ff</ogc:Literal>
        <ogc:Literal>-5</ogc:Literal>
        <ogc:Literal>0</ogc:Literal>
        <ogc:Literal>5</ogc:Literal>
        <ogc:Literal>10</ogc:Literal>
        <ogc:Literal>15</ogc:Literal>
        <ogc:Literal>20</ogc:Literal>
        <ogc:Literal>25</ogc:Literal>
        <ogc:Literal>30</ogc:Literal>
      </ogc:Function>
    </ogc:Function>
</Transformation>
4
  • Thanks! I hope this works. Will let you know. Just one more question: Is it wise to do this in the same SLD, or maybe in separate SLD-files (creating different layers). What do you think? Since you have to compute the Barnes Surface again I don't see the need to do this in the same SLD-file.
    – Trisha
    Commented Dec 3, 2018 at 14:21
  • It's up to you. It might be easier to manage should you want to change a parameter if they are both in the same file. Personally, I would write a new transformation that returns the surface and its contour so it is computed once only.
    – JGH
    Commented Dec 3, 2018 at 14:24
  • I am fairly new to the geo-world and writing a new transformation is not something I can do yet. But thanks for the advice :)
    – Trisha
    Commented Dec 3, 2018 at 14:44
  • The code for making contour lines still does not work. When I put the code in a separate SLD-file I get the following message: 'Parameter ff is not among the process parameters: [data, brand, levels...etc]'. But I need this in the code for the Barness Surface. When it is not inside the contour transformation it works fine.
    – Trisha
    Commented Dec 3, 2018 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.