我有德克萨斯州炼油厂的数据集(此处为 GeoJSON - https://pastebin.com/R0D9fif9):
Name,Latitude,Longitude
Marathon Petroleum,29.374722,-94.933611
Marathon Petroleum,29.368733,-94.903253
Valero,29.367617,-94.909515
LyondellBasell,29.71584,-95.234814
Valero,29.722213,-95.255198
Exxon,29.743865,-95.009208
Shell,29.720425,-95.12495
Petrobras,29.722466,-95.208807
我想用这些点创建一张打印的地图。但在给定的分辨率下,它们靠得太近了。
由于传说中应该提到每个炼油厂,所以我无法聚类。所以我想
获取质心 - 这很容易
import json import csv from shapely.geometry import shape, Point, MultiPoint with open('refineries.csv', 'rU') as infile: reader = csv.DictReader(infile) data = {} for row in reader: for header, value in row.items(): try: data[header].append(value) except KeyError: data[header] = [value] listo = list(zip(data['Longitude'], data['Latitude'])) points1 = MultiPoint(points=listo) points = MultiPoint([(-94.933611, 29.374722), (-94.903253, 29.368733), (-94.909515, 29.367617), (-95.234814, 29.71584), (-95.255198, 29.722213), (-95.009208, 29.743865), (-95.12495, 29.720425), (-95.208807, 29.722466)]) print(points.centroid)
将所有点从质心移开,直到达到所有点之间的最小距离
你可以在这里帮帮我吗?提前致谢!