In my GeoServer SLD I need to place a symbol (particularly a piechart) exactly on Centroid of the result of Intersection of 2 geometry:

  • geom field from my PostGIS table AND
  • environment variable WMS_BBOX

My aim is to place my Piechart on centroid of shown part of a polygon (an not on centroid of the whole polygon itself).

Ian Turton commented on my previous question with the following Geometry element in SLD, and to use it in <PointSymbolizer>:

  <ogc:Function name="intersection">
    <ogc:Function name="env">

The problem is, with the above Geometry (of intersection between geom field and WMS_BBOX) the piechart is shown in every geometry element of my multipolygon table. And this is surely not desirable.

-gambar piechart per polygon-

This effect is similar to forcing a <PointSymbolizer> Rule (below) to a multipolygon table.

            <Fill><CssParameter name="fill">#FF0000</CssParameter>

The above style enforcement gives the below layer (these islands belong to 1 row of a multipolygon table).

enter image description here

Again this is not desirable.

So then i tried the <ogc:Function name="centroid">. Thinking that this is equivalent to a PostGIS command of

        geometry_field, --of my multipolygon table

... then I wrote the following in my SLD:

    <ogc:Function name="centroid">
        <ogc:Function name="intersection">
            <ogc:Function name="env">

However my WMS preview throws this error:

code:"internalError:Rendering process failed
Filter Function problem for function centroid argument #0 - expected type Geometry

This is as if Centroid argument expects a geometry type but Intersection argument gives non-geometry type. The GeoServer Geometric functions reference however, while clearly states the type of arguments input, does not states clearly the type of the output.


  • why does centroid argument fail on my intersection?
  • how to solve it?

My playground:

  • GeoServer 2.14.3 (with chart extension)
  • Apache Tomcat 8.5.32 Server
  • Windows 10 Pro 64-bit on Xeon E5-1660 3GHz, 32GB memory
  • PostgreSQL 9.6.11, PostGIS 2.5
  • Wait, after another extra patience I zoom/pan the GeoServer layer preview that initially throws "Filter Function problem for function centroid argument #0 - expected type Geometry". It appears that in some certain area of the map, GeoServer throws the error message, while not in some other. I am pretty sure that the area with error message, there's invalid geometry. I think when geometry is invalid, Intersection throws error message, and in turn Centroid argument will throw error that it gets unexpected data type (that is the error message as oppose to a geometry). – Rino Jun 24 '19 at 6:52
  • please use the edit link to update your question rather than using comments to add information – Ian Turton Jun 24 '19 at 7:24
  • I think your geometry is called "the_geom" not "geom" hence the error message – Ian Turton Aug 9 '19 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.