从另一个GeodataFrame中替换GeodataFrame中多边形的ID值

发布于 2025-01-24 18:21:38 字数 478 浏览 3 评论 0原文

我在另一个较大的单个多边形内有多边形,我希望能够将以前多边形的ID值(例如)替换为后者的ID值。

假设我有一个带有3个多边形的GeodataFrame,它们的ID为[8,20,55]。现在,这些多边形实际上在另一个具有[2]的ID的较大多边形(第二个GeodataFrame)内。我想知道如何将[8,20,55]的值从第一个GeodataFrame转换为[2,2,2]根据较大的来自第二个GeodataFrame的多边形。从概念上讲,图像看起来像这样:

“

I have polygons inside another bigger single polygon and I want to be able to replace the ID values (for example) of the former polygon to that of the latter.

Suppose I have a geodataframe with 3 polygons and the IDs of them are [8, 20, 55]. Now, these polygons are actually inside another bigger polygon (second geodataframe) with an ID of [2]. I want to know how it is possible to convert the values of [8,20,55] from the first geodataframe to [2,2,2] according to the bigger polygon from the second geodataframe. Conceptually the image looks like this:

this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再浓的妆也掩不了殇 2025-01-31 18:21:38

使用 sjoin

gdf1['ID'] = gdf1.sjoin(gdf2, how='left', predicate='within')['ID_right']

Use sjoin:

gdf1['ID'] = gdf1.sjoin(gdf2, how='left', predicate='within')['ID_right']
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文