[Geoserver-users] Labeling polygons at centroid point

Hi all,
It is stated in the documentation that by default polygons are labeled only once at centroid point, but whatever parameters I define it always repeats a label within a polygon at some fixed intervals.

Does it work properly for anyone?

My YSLD style looks at follows

feature-styles:
- rules:
  - symbolizers:
    - polygon:
        geometry: ${geom}
        fill-color: '#da7171'
    - text:
        geometry: ${geom}
        label: ${name}
        font-family: SansSerif
        font-size: 15
        fill-color: black

and the result looks like this

image.png

The same thing happens with the SLD style.

Regards,
Eugene

Polygons are labeled once at the centroid of the visible part of the polygon. But if you make a series of tiled requests then each tile will be labeled at the centroid of the polygon on that tile. To avoid this set the geometry element of the textsymbolizer to use the centroid function on the whole geometry, See https://gis.stackexchange.com/questions/37138/polygon-label-repeated-for-each-tile for a fuller explanation.

Ian

image.png

ยทยทยท

Ian Turton