by David Crowther
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.
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.
By applying a THEMATIC type Style to the WMS layer I can then colour each feature based on the Crime Type.
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 File – Liverpool Crime Cluster
.. and copied in the sample SLD code from the Stack Exchange link.
Once I applied the new SLD file to my WMS layer, I was then able to show Stacked/Clustered Points for my Crime data.
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.
- A Text Symbolizer – to define the size, colour and font of the label being used at each Zoom/Scale.
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.
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.
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:
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:
Finally, I used the new Crime Cluster WMS within my client webGIS – MapThat – to create a high impact Crime Cluster map…
.. 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.
Comments
0 comments
Please sign in to leave a comment.