问题描述
如何检查地理点是否在给定 shapefile 的区域内?
How can I check if a geopoint is within the area of a given shapefile?
我设法在 python 中加载了一个 shapefile,但无法继续.
I managed to load a shapefile in python, but can't get any further.
推荐答案
这是对yosukesabai的回答的改编.
This is an adaptation of yosukesabai's answer.
我想确保我正在搜索的点与 shapefile 在同一个投影系统中,因此我为此添加了代码.
I wanted to ensure that the point I was searching for was in the same projection system as the shapefile, so I've added code for that.
我不明白他为什么要对 ply = feat_in.GetGeometryRef()
进行包含测试(在我的测试中,没有它似乎也能正常工作),所以我删除了它.
I couldn't understand why he was doing a contains test on ply = feat_in.GetGeometryRef()
(in my testing things seemed to work just as well without it), so I removed that.
我还改进了评论以更好地解释正在发生的事情(据我了解).
I've also improved the commenting to better explain what's going on (as I understand it).
这个网站, 这个网站,和 这个网站对投影检查很有帮助.EPSG:4326
This site, this site, and this site were helpful regarding the projection check. EPSG:4326
这篇关于检查具有纬度和经度的地理点是否在 shapefile 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!