4

I am serving a Wind as a point layer on GeoServer. In each point I have data:

  • wind speed [m/s] and
  • wind direction [degrees]

Currently I am using default style, but I would like to be able to change its representation to

Is it possible to do it with my data source and how can it be done?

2

From the GeoSolutions' blog the answer is yes. Much of the complexity the wind barbs example you link to is converting the velocity raster into points. You don't need any of that as you already have points with direction and speed.

THere isn't much documentation on windbarbs but basically you use the windbarbs:// prefix, and follow it with default(speed)[unit].

windbarbs://default(15)[kts]    

gives 15 wind intensity with knots unit of measure

windbarbs://default(9)[m/s]?hemisphere=s    

is 9 wind intensity with [m/s] unit of measure, in the south hemisphere

For full details you can study WindBarbsFactory. It looks like you can specify the speed in m/s, cm/s, km/h, mph and knots or any other unit that javax.measure.unit.UnitFormat can recognise.

Thus you can just plug speed and direction directly into the SLD.

<StyledLayerDescriptor version="1.0.0"
 xmlns="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml"
 xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.opengis.net/sld ./StyledLayerDescriptor.xsd">
   <NamedLayer>
     <Name>Wind</Name>
     <UserStyle>
       <Title>Wind</Title>
       <FeatureTypeStyle>
        <Rule>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>windbarbs://default(<ogc:PropertyName>speed</ogc:PropertyName>)[m/s]</WellKnownName>
                 <Fill>
                  <CssParameter name="fill">
                    <ogc:Literal>#f5ffff</ogc:Literal>
                  </CssParameter>
                </Fill>
                <Stroke>
                  <CssParameter name="stroke">#000000</CssParameter>
                  <CssParameter name="stroke-width">1</CssParameter>
                </Stroke>
              </Mark>
              <Size>8</Size>
              <Rotation>
                <ogc:PropertyName>direction</ogc:PropertyName>
              </Rotation>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
  • I am geting validation error on this: line 20: cvc-complex-type.2.4.d: Invalid content was found starting with element 'Fill'. No child element is expected at this point. – mycupoftea Nov 7 '17 at 12:15
  • does it work anyway? – Ian Turton Nov 7 '17 at 13:01
  • Fill should be above stroke, I'll fix it – Ian Turton Nov 7 '17 at 13:02
  • Sorry didnt know it can pass validation due to error. It does actually work! But I still need to test if drawings are correct! I still dont get, what does this SLD call so that it knows what kind of windbarb to draw? How is this defined? – mycupoftea Nov 7 '17 at 13:37
  • True, there is no validation error anymore! Thanks for fixing it and for additional explanation! – mycupoftea Nov 7 '17 at 13:55

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.