I have a WMS layer which geoserver fetches from a postgis layer. For a given query to this layer I might have two records for a given geometry. The record contains geoshape and value where value is used to create lengend graphics. How does geoserver aggregate these two records?

An example of 2 records for the same point:

|geometry                          | gridcellname | value |
|POINT(3.37531652151541 80.7506792582348)|"Y71X20"|0      |
|POINT(3.37531652151541 80.7506792582348)|"Y71X20"|137.756698608398|

Does geoserver 1. take the max value or 2. take the average value? Does the aggregation happen differently if you have a POINT() geometry verces a MULTIPOLYGON() geometry?

2 Answers 2


GeoServer does not aggregate geometries unless you tell it to. It will plot both points on your map in the order as PostGIS returns them. You just can't see the lower one.

But when you add a new Layer (Layers -> Add a new layer) you have the option "Configure new SQL view..." where you can add an sql aggregate statement to do that:

select st_union(geometry), gridcellname, avg(value)
group by gridcellname

Of course you can change avg() to max(), min(), sum() or whatever you need.

If your PostGIS layer is somehow big, you should create an Index on the "group by" column (in my example that would be gridcellname) to gain good performance.


GeoServer (by default) doesn't do aggregation it will draw both points one on top of the other. The draw order will be in the order it fetches them from the datasource (so probably based on primary key in your case).

The type of geometry makes no difference to this behaviour.

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.