I have the timezone polygons in my database and create a layer to it.

Now I try to apply some style but I can't find a way to put all zone labels at bottom.

Already read this http://docs.geoserver.org/stable/en/user/styling/sld-reference/labeling.html and this http://docs.geoserver.org/2.1.1/user/styling/sld-reference/labeling.html.

The result until now: https://i.stack.imgur.com/RJOYU.png

My style is

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
      <Title>Polygon Timezone Style</Title>
      <Abstract>A Timezone polygon style</Abstract>
          <Abstract>A Timezone polygon style</Abstract>
            <CssParameter name="fill">#f5a6ad</CssParameter>
              <CssParameter name="fill-opacity">0.2</CssParameter>
              <CssParameter name="stroke">#9c0c1f</CssParameter>
              <CssParameter name="stroke-width">0.1</CssParameter>

           <CssParameter name="font-family">Arial</CssParameter>
           <CssParameter name="font-size">9</CssParameter>
           <CssParameter name="font-style">normal</CssParameter>

  • Have you tried using other anchor points (1,1 or 0.5,0.5) just to see if they are working? It looks like the label point is the centroid of the polygon so even if the <AnchorPoint> was in the bottom right (0,0) it would just be the bottom right of the center(I could be wrong). I would say you could use the displace but since they are so irregular it probably wouldn't work. Oct 7, 2016 at 14:37
  • AnchorPoint changed nothing. I think I can remove it.
    – Magno C
    Oct 7, 2016 at 16:05

1 Answer 1


I think you could lash something up from a combination of functions but it might be easiest to pre-calculate a position and store it in a shapefile or database table.

A possible SLD might be (untested):

      <ogc:Function name="geomFromWKT">
        <ogc:Function name="getX">
          <ogc:Function name="centroid">
         <![CDATA[, -85)]]

Which would be fine until you zoom in and then they are lost, so you would really need to play with the predefined variables (wms_bbox)

 <ogc:Function name="env">

and try to intersect a vertical line from the centroid to the south pole with it to get a label point. However at that point you may well find it easier to write a custom function.

  • Ya I was thinking you could create a point layer in the locations you wanted to be labeled and only render the labels. This would just be a workaround though. Oct 7, 2016 at 15:29
  • Jesus iant... your SLD is too tricky for me. As all timezones have same width at bottom I think I could try the Chris approach. Maybe finding the 180 / 24 , y position....
    – Magno C
    Oct 7, 2016 at 15:52
  • 1
    I agree this demands more for a custom function taking into account the area of visualization, clipping to it, and then getting the a point of the lowest part of the polygon (centroid might not work for some polygons) Oct 7, 2016 at 15:55

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.