使用Python GeoPandas进行多边形点分析
有一个日期框,包含:使用Python GeoPandas进行多边形点分析,python,pandas,geopandas,Python,Pandas,Geopandas,有一个日期框,包含: 0 1 POLYGON ((37.787073 55.74702199999999, 37.7843... 1 POINT (37.34519 55.73756) 1 1 POLYGON ((37.787073 55.74702199999999, 37.7843... 2 POINT (37.23459 56.23456) 2 1 POLYGON ((37.787073 55.74702199999999, 37.7843...
0 1 POLYGON ((37.787073 55.74702199999999, 37.7843... 1 POINT (37.34519 55.73756)
1 1 POLYGON ((37.787073 55.74702199999999, 37.7843... 2 POINT (37.23459 56.23456)
2 1 POLYGON ((37.787073 55.74702199999999, 37.7843... 3 POINT (36.29575 55.23458)
3 2 POLYGON ((37.458311 55.803885, 37.464054 55.80... 1 POINT (37.34519 55.73756)
4 2 POLYGON ((37.458311 55.803885, 37.464054 55.80... 2 POINT (37.23459 56.23456)
5 2 POLYGON ((37.458311 55.803885, 37.464054 55.80... 3 POINT (36.29575 55.23458)
同时,geopandas不允许使用几何图形类型定义2列。点是几何体数据类型,但多边形不是
Int64Index: 6 entries, 0 to 5
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 place_id 6 non-null int64
1 polygon_zone 6 non-null object
2 user_id 6 non-null int64
3 geometry 6 non-null geometry
dtypes: geometry(1), int64(2), object(1)
我想检查这样一个点的出现:
result['result']=result['geometry']。在(多边形(result['Polygon\u zone'))内
但是,这种方法不起作用,请告诉我如何解决这个问题。
谢谢你的帮助 很难说您是如何使用带有/2个几何体的GDF的,但您可能希望使用sjoin
,这将返回一个GDF,然后您可以从中提取所需内容
gpd.sjoin(PolyDF, PointDF)
如果你需要解构你拥有的单一GDF。。。不确定要带什么特殊的颜色
如果你能加上你是如何得出初始地理数据框的,那会很有帮助
PolygonDF = result[["place_id", "polygon_zone"]]
PolygonDF.columns = ["place_id", "geometry"]
PointDF = result[["user_id", "geometry"]]