将包含多边形的列匀称地应用于 Polygon()

Apply a column containing polygon to Polygon() shapely

我有一个数据框,其中包含一个名为 NewPolygon 的列:

NewPolygon
[(1.23,10),(4.4, 10)...]
[(16.0,10),(8.1, 10)...]
[(2.2,10),(0, 10)...]

我的代码:

from shapely.geometry import Point
from shapely.geometry.polygon import Polygon

polygon = pd.read_csv(file_path)

point = Point(10, 1.1)

polygon = Polygon() ####How to apply the value from column `NewPolygon` here iteratively
print(polygon.contains(point))

如何将 NewPolygon 中的所有值迭代地应用到 Polygon()? Polygon()取一个元组列表作为值如Polygon([(1.23,10),(4.4, 10)...])

简单地说,使用,Series.transform:

df['NewPolygon'] = df['NewPolygon'].transform(Polygon)

要对存储在 NewPolygon 列中的多边形对象使用方法,请使用:

df['NewPolygon'].apply(lambda p : p.contains(point))