Wednesday 18 May 2016

openlayers 2 - PointStacker - Random locations at different zoom level


I'm applying PointStacker transformation on one of my layers using Geoserver 2.5.2 and OpenLayers 2.


I know, that I have 7 datapoints located on the exact same location. However, when I change the zoom level the stacked point is moving around randomly. I would've thought that the stacked point's location is calculated by the mean of the vector points being stacked. In other words, if they are located at the same location, it shouldn't move around changing zoom levels.


What am i doing wrong?


zoom level 7: zoom level 7


zoom level 8: enter image description here


zoom level 9: enter image description here


zoom level 10: enter image description here


zoom level 11: enter image description here



Answer




Your assumption about how PointStacker calculates the cluster point's location is incorrect. It doesn't use centre of mass in the way you'd expect.


The bounds of the images request are broken up into a grid and clusters are created for each cell of that grid. So if you have what looks to you like a natural cluster, e.g. 3 points close to each other, they will only be clustered together if all 3 are in the same grid cell. If they fall into 3 grid cells they will be assigned to 3 separate clusters.


As you zoom in the points do not land in the same grid cell as in the previous image and therefore the cluster is given a new location relative to the image's width and height.


This is not the most intuitive behaviour but it does make for a much simpler clustering algorithm. You can see the code here: https://github.com/geotools/geotools/blob/master/modules/unsupported/process-feature/src/main/java/org/geotools/process/vector/PointStackerProcess.java


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...