Pergunta

for example: here is a grass feature like this:

  • id,area, level
  • 1,geometry, 24
  • 2,geometry, 56
  • ...

i wount to write a sld file that display color according to the attribute level, like this :

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" 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"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name>grass</Name>
    <UserStyle>
      <Name>grass</Name>
      <Title>grass polygon</Title>
      <Abstract>grass fill with level</Abstract>
      <FeatureTypeStyle>
        <Rule>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">rgb(**level**, 0, 255)</CssParameter>
            </Fill>
            <Stroke />
          </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
Foi útil?

Solução

Have a look at the categorize and interpolate functions: http://docs.geoserver.org/latest/en/user/styling/sld-tipstricks/transformation-func.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top