5

This is not a duplicate of: how to display polygons as points until certain zoom level?

I want to do this with Geoserver v2.5.5 if possible (not openlayers).

Basically - I have a layer of polygons, which look great when zoomed in, but are nigh on impossible to see when zoomed out to a reasonable level.

I've tried using SLD to add a heavier stroke weight to the poly's, but it just looks rubbish (I get these weird looking triangles that are in no way representative of the poly). So I've come the conclusion that I'll need to display points instead when user is zoomed out.

I understand that I could just publish two layers and handle the conditional zoom logic client side - but, c'mon! Surely Geoserver should do the heavy lifting for me ;)

So bottom line - is it possible to publish a layer in Geoserver that will display points at one zoom level, and poly's at another?

EDIT:

Just to clarify: I don't need an actual point geometry, I just need to style polygon geometries to display like points at certain zoom levels.

2 Answers 2

5

If you style your polygon with a point symbolizer it will be displayed by a point. So all you need is two symbolizers (one point, one polygon) in a pair of rules with scale constraints on them.

EDIT:

Here's a simple SLD example:

<FeatureTypeStyle>
    <Rule>
        <MaxScaleDenominator>500000</MaxScaleDenominator>
        <PolygonSymbolizer>
            <Fill>
                <CssParameter name="fill">rgba(255, 255, 255, 0)</CssParameter>
            </Fill>
            <Stroke>
                <CssParameter name="stroke">#FF4000</CssParameter>
                <CssParameter name="stroke-width">1</CssParameter>
            </Stroke>
        </PolygonSymbolizer>
    </Rule>
    <Rule>
        <MinScaleDenominator>500000</MinScaleDenominator>
        <PointSymbolizer>
            <Graphic>
                <Mark>
                    <WellKnownName>circle</WellKnownName>
                    <Fill>
                        <CssParameter name="fill">#FF0000</CssParameter>
                    </Fill>
                </Mark>
                <Size>10</Size>
            </Graphic>
        </PointSymbolizer>
    </Rule>
</FeatureTypeStyle>
3
  • If you find that your small polygons do not appear even as points when zoomed out then try disabling "Support on the fly geometry simplification" in your store settings. Following an upgrade to a version which supports this feature it is enabled by default though it may appear disabled in the UI. Re-save your store settings to disable simplification
    – user19292
    Aug 16, 2016 at 7:59
  • This is exactly what I want, I would like to hide geographical hydro lines and roads when zoomed beyond say zoom 15 because the features are too many and slow the server. But I am simply unable to find where I edit this SLD XML... Do I need to edit within the geoserver data folders? Is there not a GUI area to atleast edit from a text box like feature styles?
    – wired00
    Mar 6, 2017 at 21:40
  • @wired00 there is a style editor under the styles menu in GeoServer
    – Ian Turton
    Mar 7, 2017 at 8:43
2

I'm not aware of a point/polygon geometry so you will have to publish two layers. I've done this same effect before adding the two different layers into a layer group and using min/max zoom level scales on each sld file so when zoomed in you see the polygon layer and when zoomed out only the centroid points show.

1
  • Agreed, this was my fallback option. I understand there is no point/poly geometry, but I was hoping there may be a way to use the SLD styling approach to manipulate poly's into looking like points..
    – danwild
    Apr 10, 2015 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.