如何使用 Django 和 geopy 查找纬度/经度是否落在某个区域

发布于 2024-09-02 02:08:33 字数 138 浏览 3 评论 0 原文

我正在尝试创建一个 Django 应用程序,它将接受输入的地址并返回该人将投票的政治种族列表。我有所有地区的地图(PDF)。我知道我可以使用 geopy 将输入的地址转换为坐标。如何在 Django 中定义选民选区,以便我可以运行查询来查看这些坐标属于哪些选区?

I'm trying to create a Django app that would take an inputted address and return a list of political races that person would vote in. I have maps of all the districts (PDFs). And I know that I can use geopy to convert an inputted address into coordinates. How do I define the voter districts in Django so that I can run a query to see what districts those coordinates fall in?

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

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

发布评论

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

评论(1

笑脸一如从前 2024-09-09 02:08:33

这是一个非常重要的问题,范围太大,无法在此详细回答。简而言之,您需要使用 GeoDjango (贡献)。有一个部分专门用于导入空间数据

加载数据后,您可以使用 spatial查找以查找特定坐标与哪个区域相交。

至于从哪里获取选民选区数据,您可以从www.data.gov 的地理数据目录。

This is a non-trivial problem too large in scope to answer in specific detail here. In short, you'll need to use GeoDjango (part of contrib). There is a section dedicated to importing spatial data.

Once you have your data loaded, you can use spatial lookups to find what district a particular coordinate intersects.

As to where to get the voter district data, you might start with www.data.gov's geodata catalog.

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