26

I see MerseyViking has recommended a quadtree. I was going to suggest the same thing and in order to explain it, here's the code and an example. The code is written in R but ought to port easily to, say, Python. The idea is remarkably simple: split the points approximately in half in the x-direction, then recursively split the two halves along the y-...


22

If you want a clusterer like redfin then check out my Leaflet.markercluster: https://github.com/Leaflet/Leaflet.markercluster/blob/master/example/marker-clustering-realworld.388.html https://github.com/danzel/Leaflet.markercluster It is fully animated etc etc :)


17

I've done a bit of work on this in GeoTools/GeoServer by extending the Heatmap Rendering Transformation to support geometries other than points. It's not finished yet, but you can get the feature branch from my repository on GitHub. The screenshot is of GPS tracks from when I worked as a pizza delivery driver.


15

Here is a good tutorial for doing exactly that using MapBox and TileMill: A heatmap for all your runs in RunKeeper


15

The Concave Hull plugin adds Shared Nearest Neighbor Clustering to processing


13

Here is a solution based on Find clusters of points based distance rule, but using the distm function from the geosphere package: library(sp) library(rgdal) library(geosphere) # example data from the thread x <- c(-1.482156, -1.482318, -1.482129, -1.482880, -1.485735, -1.485770, -1.485913, -1.484275, -1.485866) y <- c(54.90083, 54.90078, 54.90077, 54....


11

There are functions for computing true distances on a spherical earth in R, so maybe you can use those and call the clustering functions with a distance matrix instead of coordinates. I can never remember the names or relevant packages though. See the R-spatial Task View for clues. The other option is to transform your points to a reference system so that ...


10

In traditional cartography, marker clustering is called aggregation or sometimes amalgamation. It is part of model generalization: When zooming out, some detailed concepts (e.g. the tree) disappear to be replaced by less detailed aggregated forms (e.g. the forest). Many good examples can be found in good cartography books. Here are two examples from this ...


10

you can check out k-means clustering algorithm here. In data mining, k-means clustering is a method of cluster analysis which aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean. This results into a partitioning of the data space into Voronoi cells. kmeans-postgresql implementation ...


10

I've done some research. I took some points in two coordinate systems non metric (WGS84) and metric (Poland 1992). I used this code: from scipy import loadtxt from sklearn.cluster import Birch import matplotlib.pyplot as plt data84 = loadtxt("/home/damian/workspace/84.csv", delimiter=",") data90 = loadtxt("/home/damian/workspace/90.csv", delimiter=",") ...


10

I was able to get some quite good results, with thanks to Michael Stimson for the suggestion. I had forgotten about the "buffer out, buffer back in" trick (this can also help reduce the number of holes that need to be fixed). This involves a positive buffer (which tends to fill in gaps and holes) followed by a negative buffer (to shrink back to near ...


9

You can use Vector > Analysis Tools > Distance Matrix, and a join to achieve what you ask. I will use qgis sample data airport's layer to exemplify. This is a small dataset so I'm not sure how it will go with a 275000 points shapefile. 1. Create a distance matrix using your layer as both destination and target. Don't forget to tick "Use only the nearest (...


9

Previously I'd written a hierarchical clustering algorithm that operated on small groups of points, but it did not scale well to an 8000 point cloud. After some tinkering I got a revamped version to work. It does 8000 points in under 30s on a server, scaling at something approximating N*log(N). First two tables definitions are required: CREATE TABLE pt ( ...


9

you can try this (did this in QGIS 2.16) fixed distance buffer each point by 250m (this is half the required distance between points) then dissolve all on the result of that then use multipart to singlepart to split each cluster into its own feature add a field (using the expression @row_number) to assign a unique ID to each cluster. you then get ...


9

If I understand you right you want to cluster lines that is about the same without respect to direction. Here is an idea that I think could work. split the lines in start point and end point Cluster the points and get cluster id Find lines with the same combination of cluster id. Those are a cluster This should be possible in PostGIS (of course :-) ) ...


8

Starting from the custom example from the github repo, modify the iconCreateFunction to add a different css class based on the size of the cluster: iconCreateFunction: function (cluster) { var markers = cluster.getAllChildMarkers(); var n = 0; for (var i = 0; i < markers.length; i++) { n += markers[i].number; } var small = n < 200; var ...


7

There's a lot of options and in fact I struggled through the same question a while back on some of my applications. And for our different products we ended up with different solutions. So you have to ask yourself Are all of the singleton icons on the map of the same "kind" - same shape and color? If they're not, do they all live on 1 layer, or multiple ...


7

This may not be the most elegant solution, but, with some fine-tuning of the timeout durations and customization of the cluster icons, I think you can get the effect you are looking for. See this example. The trick is to first create a marker and set the map attribute in the marker options object. This adds the marker to the map with the nice drop ...


7

I'd take a look at the Spatstat package. The entire package is dedicated to analysing spatial point patterns (sic). There's an excellent ebook written by Prof. Adrian Baddeley at the CSIRO which contains detailed documentation, how-to's and examples for the entire package. Take a look at chapter 19 for "Distance methods for point patterns". That said, I'm ...


7

You do not have a uniform random field, so attempting to analyze all of your data at once will violate the assumptions of any statistic you choose to throw at the problem. It is unclear from your post if your data is a marked point process (i.e, diameter or height associated with each tree location). If this data is not representing a marked point process I ...


7

You can use a hierarchical clustering approach. By applying hclust and cutree you can derive clusters that are within a specified distance. Another way is to use the spdep package and calculate a distance matrix using dnearneigh. If you would like code for the dnearneigh approach let me know and I will post it. require(sp) require(rgdal) d=40 # Distance ...


6

Maybe this answer comes 2 years too late, but anyway. To my knowledge, spatial clustering requires a defined neighborhood to which the clustering is constrained, at least at the beginning. The kulldorf function in the SpatialEpi package allows for spatial clustering based on aggregated neighborhoods. further the DBSCAN statistic available from the fpc ...


6

Discussion following a closely related post revealed a simple, effective solution: to find the "hills", turn the grid upside-down (by negating its values) and find watersheds. The hills are sinks and watershed boundaries partition the grid into those sinks.


6

OpenLayers has also a cluster strategy. All you need to do is to specify as strategy in the vector layer. The solution is very "simple" for the moment, simply reduces the number of points depending on the zoom level. If you need something more awesome you will need to program it by yourself and your needs. Take a look also to SelectFeature control which ...


6

Thanks to @whuber for setting me on the right track here. Looks as if there will be no additional answers forthcoming, so will settle this question by posting my own observations that may be useful for others learning about distances, clustering, and projections. The following R code, using the geosphere, rgdal, and sp packages demonstrates that careful ...


6

You might check out the following: Disperse Markers tools for representations. (ArcInfo aka Advanced only) Collect Events with rendering tool. ESRI tech article 22695 using the ESRI label engine to offset overlapping point symbols ArcObjects SDK point dispersal samples ETGEowizards disperse points tool. (Paid version) I've never tried this so it may be ...


6

See if this algorithm gives enough anonymity for your data sample: start with a regular grid if polygon has less than threshold, merge with neighbor alternating (E, S, W, N) spiraling clockwise. if polygon has less than threshold, go to 2, else go to next polygon For example, if the minimum threshold is 3:


6

One quick and dirty way uses a recursive spherical subdivision. Beginning with a triangulation of the earth's surface, recursively split each triangle from a vertex across to the middle of its longest side. (Ideally you will split the triangle into two equal-diameter parts or equal-area parts, but because those involve some fiddly calculation, I just split ...


6

You need to do this in a two-stage process using the Vector->Analysis Tools->Mean Coordinates tool in the second step. This tool will return the mean coordinates for sets of point within a layer if they have a unique ID field. So, if you have a polygon layer which defines your areas, do a spatial join (Vector->Data Management->Join attributes ...


6

Thanks to @gene and https://geoscripting-wur.github.io/AdvancedRasterAnalysis/ I can now answer my question (copied and modified): library(raster) # create some raster data r <- raster(ncols=12, nrows=12) set.seed(0) r[] <- round(runif(ncell(r))*0.7 ) r[r==0]<-NA # extend r with a number of rows and culomns (at each side) # to isolate clumps ...


Only top voted, non community-wiki answers of a minimum length are eligible