GeoServer – Creating Stacked Points

Marketing
Marketing
  • Updated

by David Crowther

stacked_points_1.png

Question:

Using GeoServer is it possible to group individual Points into Stacked Point Objects?

Answer:

Yes, utilsiing the power of Style Layer Descriptors (SLDs) you can publish individual Point Geometry as Stacked Points where a textual value denotes the number of point objects clustered.

stacked_points_2.jpg

Firstly, in GeoServer you will need to setup a DATA SOURCE connection to your source data and then publish that as a WMS layer. Here I am publishing a Crime Table from my PostGIS database and applying the generic Point STYLE.

stacked_points_3.jpg

By applying a THEMATIC type Style to the WMS layer I can then colour each feature based on the Crime Type.

stacked_points_4.jpgstacked_points_5.jpg

This is a high impact WMS layer, however as there are so many Point objects the map doesn’t help us to identify where Crimes are Clustering.

After doing a little research I found a link on Stack Exchange with the sample SLD code that would create Stacked Points where individual Points are clustered together - https://gis.stackexchange.com/questions/98536/geoserver-point-stacker-does-identify-work-on-non-clustered-points

In my GeoServer Instance I then created a New Style FileLiverpool Crime Cluster

stacked_points_6.jpg

.. and copied in the sample SLD code from the Stack Exchange link.

stacked_points_7.jpg

Once I applied the new SLD file to my WMS layer, I was then able to show Stacked/Clustered Points for my Crime data.

stacked_points_8.jpg

This was a great start!.... but like any good Thematic Styled map I wanted to then apply colours to make it more obvious where there were a high, medium and low number of Stacked Point objects.

Checking the SLD it was clear that there were individual RULES for clustering Points at different Zoom/Scales, where each Rule applied:

  • A Point Symbolizer – to set the Colour and Size of each Stacked Point.

stacked_points_9.jpg

  • A Text Symbolizer – to define the size, colour and font of the label being used at each Zoom/Scale.

stacked_points_10.jpg

In the original SLD there were 2 Rules which defined how the Point Stacker would style the WMS between two different Scales. However, to make this SLD even more useful I wanted to apply different Sizes to the Point Symbolizer, not based on Zoom/Scale but based on the number of Points being Stacked – thus hopefully making the High Numbers have a Larger Symbol.

With some further research I found another Stack Exchange link that provided an SLD where the Stacked Point Objects now changed size according to the number of Points being Stacked - https://gis.stackexchange.com/questions/261711/point-stacker-in-combination-with-other-filter

Here each Stacked Point has a COUNT value associated to it, and this SLD applied a different sized brown Circle based on the numeric Count value.

stacked_points_11.jpg

Here is an example of the SLD, using a PropertyIsBetween Rule to define the Size of the Point Symbol using the COUNT value for each object.

stacked_points_12.jpg

Almost there!... but I now wanted to apply individual Colours against each Count range so that we could show High Clusters with a Red colour and Low Clusters with a Blue Colour – with my ranges looking something like this:

stacked_points_13.jpg

To do this, I edited the SLD by:

  • Creating 6 Rules – using the PropertyIsBetween syntax to create the ranges as above
  • Edited the Point Symbolizer – to change their Size and Colour based on the Count value
  • Edited the Text Symbolizer – to apply the same Colour as the Point Symbolizer

Once I then applied this updated SLD the WMS looked like this:

stacked_points_14.jpg

Finally, I used the new Crime Cluster WMS within my client webGIS – MapThat – to create a high impact Crime Cluster map…

stacked_points_15.jpg

.. and because MapThat can show attributes from WMS Layers, I created an Info Bubble that allows User to interrogate the Crime Count values across the map.

stacked_points_16.jpg

Was this article helpful?

1 out of 1 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.