개요
geoserver에 wms 스타일 중 ogc:Filter를 사용하여 필드 값에 따라 특정 스타일을 부여하는 작업을 하려고 함
이전에 만들었던 경량화 읍면동 파일에 mesure_cnt 명의 컬럼을 추가하고 이 컬럼에 1~ 16 까지의 랜덤한 숫자를 부여하여 일정 구간 마다 opacity 값을 변경 아래의 결과물을 만들었다.
1. 스타일 작업
geoserver 폴리곤 스타일 가이드를 참고하였다. https://docs.geoserver.org/stable/en/user/styling/sld/cookbook/polygons.html
Attribute-based polygon
<FeatureTypeStyle> <Rule> <Name>SmallPop</Name> <Title>Less Than 200,000</Title> <ogc:Filter> <ogc:PropertyIsLessThan> <ogc:PropertyName>pop</ogc:PropertyName> <ogc:Literal>200000</ogc:Literal> </ogc:PropertyIsLessThan> </ogc:Filter> <PolygonSymbolizer> <Fill> <CssParameter name="fill">#66FF66</CssParameter> </Fill> </PolygonSymbolizer> </Rule> <Rule> <Name>MediumPop</Name> <Title>200,000 to 500,000</Title> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThanOrEqualTo> <ogc:PropertyName>pop</ogc:PropertyName> <ogc:Literal>200000</ogc:Literal> </ogc:PropertyIsGreaterThanOrEqualTo> <ogc:PropertyIsLessThan> <ogc:PropertyName>pop</ogc:PropertyName> <ogc:Literal>500000</ogc:Literal> </ogc:PropertyIsLessThan> </ogc:And> </ogc:Filter> <PolygonSymbolizer> <Fill> <CssParameter name="fill">#33CC33</CssParameter> </Fill> </PolygonSymbolizer> </Rule> <Rule> <Name>LargePop</Name> <Title>Greater Than 500,000</Title> <ogc:Filter> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>pop</ogc:PropertyName> <ogc:Literal>500000</ogc:Literal> </ogc:PropertyIsGreaterThan> </ogc:Filter> <PolygonSymbolizer> <Fill> <CssParameter name="fill">#009900</CssParameter> </Fill> </PolygonSymbolizer> </Rule> </FeatureTypeStyle>
<title> : 타이틀의 값이 범례에 표현될 값을 의미함
<ogc:PropertyIsLessThan> : 미만
<ogc:PropertyIsGreaterThanOrEqualTo> : 같거나 큼
<ogc:PropertyIsGreaterThan> : 이상
데이터 > 스타일 > Layer Preview(탭 매뉴)
사용 SLD CODE
<?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></Name>
<UserStyle>
<Title>A azure polygon style</Title>
<FeatureTypeStyle>
<Rule>
<Name>0</Name>
<Title>0</Title>
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
<CssParameter name="fill-opacity">0.0</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">0.5</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>1 ~ 5</Name>
<Title>1 ~ 5</Title>
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>5</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:And>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
<CssParameter name="fill-opacity">0.3</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">0.5</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>6 ~ 10</Name>
<Title>6 ~ 10</Title>
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>6</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>10</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:And>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
<CssParameter name="fill-opacity">0.6</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">0.5</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>11 ~ 15</Name>
<Title>11 ~ 15</Title>
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>11</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>15</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:And>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
<CssParameter name="fill-opacity">0.8</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">0.5</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>16 ~ </Name>
<Title>16 ~ </Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>mesure_cnt</ogc:PropertyName>
<ogc:Literal>16</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
<CssParameter name="fill-opacity">1</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">0.5</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
'꿀팁 - Geoserver' 카테고리의 다른 글
Geoserver WPS plugin & OpenGXT 설치하기 (1) | 2019.12.05 |
---|---|
Geoserver oracle plugin 설치하기 (0) | 2018.12.14 |
Geoserver Tile Cache 설정하기 (6) | 2018.12.06 |
지오서버 레이어그룹 설정 (0) | 2018.11.06 |
지오서버 서비스 설정 (0) | 2018.11.06 |