两个地质地板的交汇处发出警告“两个地层的索引不同。”还有很少的比赛

发布于 2025-01-28 03:52:21 字数 804 浏览 4 评论 0原文

我正在使用地ge以查找点和多边形之间的相交。 当我使用以下内容时:

intersection_mb = buffers_df.intersection(rest_VIC)

我会收到此输出的警告,基本上说没有交集:

0         None
112780    None
112781    None
112782    None
112784    None
      ... 
201314    None
201323    None
201403    None
201404    None
201444    None
Length: 3960, dtype: geometry

警告消息:

 C:\Users\Name\Anaconda3\lib\site-packages\geopandas\base.py:31: UserWarning: The indices of the two GeoSeries are different.
 warn("The indices of the two GeoSeries are different.")

我寻找任何建议,发现我可以通过为两个地理系设置CRS来解决,以执行该交叉点,但这无效。

rest_VIC = rest_VIC.set_crs(epsg=4326, allow_override=True)
buffers_df = buffers_df.set_crs(epsg=4326, allow_override=True)

任何建议都会有所帮助。谢谢。

I am using geopandas for finding intersections between points and polygons.
When I use the following:

intersection_mb = buffers_df.intersection(rest_VIC)

I get this output with a warning basically saying there are no intersections:

0         None
112780    None
112781    None
112782    None
112784    None
      ... 
201314    None
201323    None
201403    None
201404    None
201444    None
Length: 3960, dtype: geometry

Warning message:

 C:\Users\Name\Anaconda3\lib\site-packages\geopandas\base.py:31: UserWarning: The indices of the two GeoSeries are different.
 warn("The indices of the two GeoSeries are different.")

I looked for any suggestions and found that I could solve by setting crs for both geoseries for which the intersection is to be performed on, but it did not work.

rest_VIC = rest_VIC.set_crs(epsg=4326, allow_override=True)
buffers_df = buffers_df.set_crs(epsg=4326, allow_override=True)

Any suggestions will be helpful. Thanks.

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

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

发布评论

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

评论(1

俯瞰星空 2025-02-04 03:52:21

element-wise 操作。从交叉点文档:

该操作以1-1的行方式工作

有一个可选的Align参数,该参数确定是否应基于索引对齐后首先基于该系列(如果为true,默认)或者,如果应根据位置进行交叉操作,则在行方面进行行。

因此,您得到的警告以及由此产生的NAN是因为您对具有无与伦比的索引的数据进行了元素的比较。当试图将数据范围与非对齐指数合并时,大熊猫会发生同一问题。

如果您试图在两个数据范围的所有行中找到从点到多边形的映射,那么您正在寻找一个空间连接,可以使用 geopandas.sjoin

intersection_mb = geopandas.sjoin(
    buffers_df,
    rest_VIC,
    how='outer',
    predicate='intersects',
)

请参阅《 合并数据以获取更多信息。

geopandas.GeoSeries.intersection is an element-wise operation. From the intersection docs:

The operation works on a 1-to-1 row-wise manner

There is an optional align argument which determines whether the series should be first compared based after aligning based on the index (if True, the default) or if the intersection operation should be performed row-wise based on position.

So the warning you're getting, and the resulting NaNs, are because you're performing an elementwise comparison on data with unmatched indices. The same issue would occur in pandas when trying to merge columns for DataFrames with un-aligned indices.

If you're trying to find the mapping from points to polygons across all combinations of rows across the two dataframes, you're looking for a spatial join, which can be done with geopandas.sjoin:

intersection_mb = geopandas.sjoin(
    buffers_df,
    rest_VIC,
    how='outer',
    predicate='intersects',
)

See the geopandas guide to merging data for more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文