3

I am trying to create an SLD to style a polygon; the goal is to create hash fill for polygon but to leave empty space between hatch and bounds of the polygon, something like this: goal

I am using this to create fill

<PolygonSymbolizer>
    <Fill>
        <GraphicFill>
            <Graphic>
                <Mark>
                    <WellKnownName>shape://slash</WellKnownName>
                    <Stroke>
                        <CssParameter name="stroke">#000000</CssParameter>
                        <CssParameter name="stroke-width">1</CssParameter>
                    </Stroke>
                </Mark>
            </Graphic>
        </GraphicFill>
    </Fill>
</PolygonSymbolizer> 
<LineSymbolizer>
    <Stroke>
        <CssParameter name="stroke">#000000</CssParameter>
        <CssParameter name="stroke-width">1</CssParameter>
    </Stroke>
</LineSymbolizer>

There is a way to use a thicker white line, but if there is some object near I wont be able to see it, so that is not an option.

4

So the option you do not like would be to add this:

<LineSymbolizer>
    <Stroke>
        <CssParameter name="stroke">#FFFFFF</CssParameter>
        <CssParameter name="stroke-width">8</CssParameter>
    </Stroke>
    <PerpendicularOffset>-4</PerpendicularOffset>
</LineSymbolizer>  

I've tested and it works but as you say it may block other objects. What you could try is something like this which aims to interior buffer the polygon, however you may find the computation overheads make it unfeasible:

<PolygonSymbolizer>
     <Geometry>
       <ogc:Function name="buffer">
          <ogc:PropertyName>the_geom</ogc:PropertyName>
          <ogc:Literal>-.1</ogc:Literal>
       </ogc:Function>
     </Geometry>  
    <Fill>
        <GraphicFill>
            <Graphic>
                <Mark>
                    <WellKnownName>shape://slash</WellKnownName>
                    <Stroke>
                        <CssParameter name="stroke">#000000</CssParameter>
                        <CssParameter name="stroke-width">1</CssParameter>
                    </Stroke>
                </Mark>
            </Graphic>
        </GraphicFill>
    </Fill>
</PolygonSymbolizer> 

Note I have not tested this successfully. Alternatively is it possible for you to pre-compute the interior buffers and just display both, one hatched with no boundary and one no fill but with a boundary?

  • 1
    It works, I only added bigger value for buffer, will accept this as correct answer. Thanks – Zoran Kokeza Mar 1 '17 at 20:47
  • Can you help me what if there is need for rotation (example angle 30 degrees) of mark can those lines be made without breaks, because graphic fill works basically just putting those marks one next to another, and then lines look weird – Zoran Kokeza Mar 3 '17 at 17:55
  • you could try custom shapes: docs.geoserver.org/stable/en/user/styling/sld/extensions/… (note technically you should start a new question for this ;) – JimT Mar 3 '17 at 18:59

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.