I would like to label the lower left corner of rectangular shaped polygons in geoserver I have looked the the functions and I am wondering how I would set up variable to perform the calculation for anchor point

Here are the filter functions I was looking at https://docs.geoserver.org/latest/en/user/filter/function_reference.html

I am thinking I could use the Geometry:boundary function somehow but I cannot figure out how to get the corner geometry. Is this possibleenter image description here

2 Answers 2


If you can make sure during preprocessing/querying your data that the lower left corner is always the n-th (e.g. first) point in the geometry data, you could use the pointN function to get this point for labeling.

Not the cleanest solution, but should work...


I think you may need to write a custom function for this, something like this should work (seems mostly right with my test cases):

public class LowerLeftFunction implements Function {
  static FunctionName NAME = new FunctionNameImpl("lowerleft", Polygon.class,
  FunctionNameImpl.parameter("polygon", Polygon.class));


  public <T> T evaluate(Object object, Class<T> context) {
    Expression polyExp = parameters.get(0);
    Polygon poly = polyExp.evaluate(object, Polygon.class);
    LineString ext = poly.getExteriorRing();
    Coordinate ll = new Coordinate(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    for (Coordinate c : ext.getCoordinates()) {
      if (c.x <= ll.x && c.y <= ll.y) {
        ll = c;
    Point pt = poly.getFactory().createPoint(ll);
    return Converters.convert(pt, context);

I'll put the whole thing up on github when it has some tests and I get a chance later.

  • Awesome, I tried pointN and endPoint and got mixed results creating a point on a corner and then labeling the point. The nth point is unfortunately in a different location on each polygon due to boundary irregularities. Dec 8, 2018 at 8:47

Your Answer

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

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