2016-11-11 23 views
0

私は以下のようにsympy.geometryパッケージを使用してポリゴンを作成しました:多角形の点をどのように反復処理しますか?

poly1 = Polygon((39.,4.), (32.,30.), (40.,10.), (42.,10.), (43.,14.)) 

ポリゴンのポイントは、経度/緯度座標です。 これで、ポリゴンを楕円(地球)に投影し、ポリゴンの面積を計算したいと考えています。

私は、次のコードを書かれている:

from pyproj import Proj 

#specify projection for the Earth using reference ellipsoid" 
wgs84=pyproj.Proj("+init=EPSG:4326") 
poly1_transformed=[] 

for point in poly1: 

    new_point = wgs84(point) 
    poly1_transformed.append(new_point) 

は、しかし、私はポリゴン内のポイントを反復処理することはできません。私はポリゴン全体を投影することができます(そして最終的には面積を計算する)ような方法がありますか?

これは私のエラーです:

TypeError         
Traceback (most recent call last) 
<ipython-input-65-0c7501bb5894> in <module>() 
    5 wgs84=pyproj.Proj("+init=EPSG:4326") 
    6 
----> 7 for point in poly1: 
    8  new_point = wgs84(point) 
    9  print (point, new_point) 

TypeError: 'Polygon' object is not iterable 

答えて

1

Polygonオブジェクトが反復可能ではありませんので、あなたが、代わりにpoly1.argsを使用することによってポイントを得ることができる:

for point in poly1.args: 
    new_point = wgs84(point) 
    poly1_transformed.append(new_point) 
関連する問題