Cute Happy Ghost
본문 바로가기
QGIS·Geo

[geoserver] OGC filter를 통해 값마다 스타일 지정해주기, 범례설정

by JENN_tech7 2022. 6. 29.
728x90
SMALL

먼저 코드부터 냅다 올리고 설명을 하겠다!

<FeatureTypeStyle>
 <Rule>
  <Name>Greater Than 800</Name>
  <Title>Greater Than 800</Title>
   <ogc:Filter>
   <ogc:PropertyIsGreaterThan>
     <ogc:PropertyName>food</ogc:PropertyName>
     <ogc:Literal>800</ogc:Literal>
   </ogc:PropertyIsGreaterThan>
 </ogc:Filter>
  <PointSymbolizer>
    <Graphic>
      <Mark>
        <WellKnownName>circle</WellKnownName>
        <Fill>
          <CssParameter name="fill">#ff5722</CssParameter>
          <CssParameter name="fill-opacity">1.0</CssParameter>
        </Fill>
      </Mark>
      <Size>15</Size>
    </Graphic>
  </PointSymbolizer>
</Rule>
<Rule>
  <Name>less Than 800</Name>
  <Title>less Than 800</Title>
   <ogc:Filter>
   <ogc:PropertyIsLessThan>
     <ogc:PropertyName>food</ogc:PropertyName>
     <ogc:Literal>800</ogc:Literal>
   </ogc:PropertyIsLessThan>
 </ogc:Filter>
  <PointSymbolizer>
    <Graphic>
      <Mark>
        <WellKnownName>circle</WellKnownName>
        <Fill>
          <CssParameter name="fill">#51abff</CssParameter>
          <CssParameter name="fill-opacity">1.0</CssParameter>
        </Fill>
      </Mark>
      <Size>15</Size>
    </Graphic>
  </PointSymbolizer>
</Rule>
<Rule>
  <MaxScaleDenominator>32000</MaxScaleDenominator>
</Rule>
</FeatureTypeStyle>

스타일 코드는 기본 1featuretypestyle과 1rule이다

이제 그 안에 rule들을 추가시켜주면 되는 것임 

나는 800을 기준으로 초과와 미만의 스타일을 달리 주고 싶었다

그래서 첫번째rule을 grater than 800으로 선언하고 ogcfilter를 추가해준다

ogc filter는 value와 경계를 설정할 수 있다

 

<ogc:PropertyIsLessThan>: 미만

<ogc:PropertyIsGreaterThanOrEqualTo>: 같거나 큼

<ogc:PropertyIsGreaterThan>: 초과  

원하는 필터를 쓰고 property에 기준이 될 value를 지정해주고, literal에 기준이 되는 값을 지정해주면 된다

나는 point라서 point심볼라이저를 썼는데 폴리곤이나 line이라면 각각 지정해주면된다

예뻐서 써본 사이트 ㅎㅎ

circle을 쓰겠다 라고 넣어주고 해당 색깔과 투명도로 채우겠다라고 지정해줌

size는 당연 사이즈~

 

 

 

 

참고ref

https://docs.geoserver.org/stable/en/user/styling/sld/cookbook/points.html#sld-cookbook-points-pointwithstyledlabel

 

Points — GeoServer 2.21.x User Manual

Points While points are seemingly the simplest type of shape, possessing only position and no other dimensions, there are many different ways that a point can be styled in SLD. Warning The code examples shown on this page are not the full SLD code, as they

docs.geoserver.org

geoserver사용할때 geoserver docs를 활용하는 것이 참 많은 도움이 되는 것 같다

 

 

728x90
LIST

댓글