简体   繁体   English

使用 GeoPandas / Shapely 查找由纬度和经度坐标定义的多边形的交叉区域

[英]Use GeoPandas / Shapely to find intersection area of polygons defined by latitude and longitude coordinates

I have two GeoDataFrames, left and right , with many polygons in them.我有两个 GeoDataFrame, leftright ,其中有许多多边形。 Now I am trying to find the total intersection area of each polygon in left , with all polygons in right .现在我试图找到左边每个多边形的总交集面积,右边的所有多边形。

I've managed to get the indices of the intersecting polygons in right for each polygon in left using gpd.sjoin, so I compute the intersection area using:我已经设法使用 gpd.sjoin 为左侧的每个多边形获取右侧相交多边形的索引,因此我使用以下方法计算相交区域:

area = left.iloc[i].geometry.intersection(right.iloc[idx].geometry).area

Where i and idx are the indices of the intersecting polygons in the two GDFs (let's assume the left poly only intersects with 1 poly in right).其中 i 和 idx 是两个 GDF 中相交多边形的索引(假设左侧多边形仅与右侧的 1 个多边形相交)。 The problem is that the area value I get does not seem correct in any way, and I don't know what units it has.问题是我得到的面积值似乎无论如何都不正确,而且我不知道它有什么单位。 The CRS of both GeoDataFrames is EPSG:4326 so the standard WSG84 projection, and the polygon coordinates are defined in degrees latitude and longitude.两个 GeoDataFrames 的 CRS 是 EPSG:4326,因此是标准的 WSG84 投影,多边形坐标以纬度和经度定义。

Does anyone know what units the computed area then has?有谁知道计算面积的单位是什么? Or does this not work and do I need to convert them to a different projection before computing the area?或者这不起作用,我是否需要在计算面积之前将它们转换为不同的投影?

Thanks for the help!谢谢您的帮助!

I fixed it by using the EPSG:6933 projection instead, which is an area preserving map projection and returns the area in square metres (EPSG:4326 does not preserve areas, so is not suitable for area calculations).我改用 EPSG:6933 投影来修复它,这是一个保留面积的地图投影,并以平方米为单位返回面积(EPSG:4326 不保留面积,因此不适合面积计算)。 I could just change my GDF to this projection using我可以使用将我的 GDF 更改为此投影

gdf.to_crs(espg=6933)

And then compute the area in the same way as above.然后以与上述相同的方式计算面积。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM