![](/img/trans.png)
[英]Python: find a method to calculate the “inner centroid” (X,Y) of a polygon
[英]How to calculate centroid of x,y coordinates in python
我有很多x,y坐標,我根據它們之間的距離聚集在一起。 現在我想計算每個x,y坐標簇的質心量度。 有沒有辦法做到這一點?
我的坐標格式為:
coordinates_cluster = [[x1,x2,x3,...],[y1,y2,y3,...]]
每個簇的最小長度為三個點,並且所有點都可以具有負x和y值。 我希望有人可以幫助我。
最好,馬丁
(我在Windows 7系統上使用帶有canopy 1.1.1(32位)的python 2.7。)
我意識到這並不難,但這里是用於計算x,y坐標的質心的代碼:
>>> c = [[1,4,-5],[3,-2,9]] # of the form [[x1,x2,x3],[y1,y2,y3]]
>>> centroide = (sum(c[0])/len(c[0]),sum(c[1])/len(c[1]))
>>> centroide
(0, 3)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.