开发者

GeoDjango: is there an out-of-the-box way to generate clusters of points?

I'm trying to compute clusters on a set of points in Python, using GeoDjango.

The problem: Given a set of points, output a set of clusters of those points. (i'm fine specifying # of clusters/cluster size/distance in advance to simplify)

There are a few solutions on the web to do clustering, so it's a well known problem. I thought that GeoDjango would handle these types of proble开发者_C百科ms out of the box, but it's not clear how - I've searched the GeoDjango documentation, Google, and a few other places, but couldn't find anything.

Before I roll my own clustering solution, I thought I'd ask to see if there's a straightforward way to do this using GEOS or another package within GeoDjango.


GeoDjango does not have any built in clustering support; this operation is not typically provided by any existing Open Source GIS application that you would be using with GeoDjango that I'm aware of.

Several sites running Django/GeoDjango (like everyblock.com) have published what their method is for clustering, but this support is not built into GeoDjango.

In general, the functionality provided by these applications is based on the underlying database support. GEOS, the library underneath PostGIS, and the general 'state of the art' (at least in the non-Java world), does not have any kind of clustering API or behavior.


As Christopher Schmidt mentioned, there doesn't seem to be any out of the box support for clustering in GeoDjango. However, if someone else runs into this issue, here's what I did:

  • Installed mlpy and numpy
  • Used the HCluster hierarchical clustering algorithm
  • Wrote a wrapper function to convert the GEOS Point objects into a matrix that mlpy could understand

Documentation at: https://mlpy.fbk.eu/data/doc/clustering.html


If anyone stumbles upon this thread:

https://github.com/biodiv/anycluster

I open sourced my geodjango clustering app. After installing it, you just need a few lines of javascript and it clusters. You can easily change some settings and use your own graphics. I also added some usage examples on github...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜