快速地理空间点聚类模块。
pysupercluster的Python项目详细描述
用于地理空间点聚类的快速python 3模块。
这是一个https://github.com/mapbox/supercluster到C++的端口,方便 包装在python模块中。初步的基准表明 比原始javascript实现快10倍。
安装pysupercluster
安装pysupercluster最简单的方法是使用pip:
pip install pysupercluster
使用pysupercluster
>>> importnumpy>>> importpysupercluster>>> points=numpy.array([... (2.3522,48.8566),# paris... (-0.1278,51.5074),# london... (-0.0077,51.4826),# greenwhich... ])>>> index=pysupercluster.SuperCluster(... points,... min_zoom=0,... max_zoom=16,... radius=40,... extent=512)>>> clusters=index.getClusters(... top_left=(-180,90),... bottom_right=(180,-90),... zoom=4)[ {'id': 0, 'count': 1, 'expansion_zoom': None, 'latitude': 48.8566, 'longitude': 2.3522}, {'id': 3, 'count': 2, 'expansion_zoom': 8, 'latitude': 51.49500168658321, 'longitude': -0.06774999999998421} ]