如何使用要素的属性填充 SLD 中的颜色



例如:这里有一个类似的草地功能:

  • id、区域、级别
  • 1,几何形状,24
  • 2,几何形状,56

我不想写一个根据属性级别显示颜色的sld文件,比如这样:

<?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>

查看分类和插值函数:http://docs.geoserver.org/latest/en/user/styling/sld-tipstricks/transformation-func.html

最新更新