PostGIS 路口故障排除

发布于 2024-09-08 07:09:23 字数 702 浏览 2 评论 0原文

我刚刚开始使用 PostGIS & Postgresql 和大多数情况下一切都运行顺利。当我试图找到 MULTIPOLYGON sa POINT 所在的位置时,我陷入了困境。我有两个单独的点,我确信它们位于我的数据库中一个且只有一个 MULTIPOLYGON 数据类型的形状内。它们不是相同的点,并且格式不同。

示例 1,我不确定它是什么格式,但查询返回了我预期的真实值(注意,我通过将数据集加载到 QGIS 并将鼠标悬停在内部的一个点上找到了这个值)。

在第二个示例中,我对位于我正在查看的形状内的地址进行了地理编码。但是,查询结果返回错误值。

我使用 shp2pgsql 将数据直接从形状文件加载到数据库中。形状文件的 SRID 是 4269(我尝试在 GeomFromText 调用期间指定 SRID 时运行下面的查询,但结果是相同的)。

这两个坐标集有什么区别?我需要做什么才能使用使用纬度/经度值的点执行相交测试?

1.) SELECT ST_Intersects((从 wardstable 中选择 the_geom,其中 gid=37), ST_GeomFromText('点(1172539 1924462)'));

2.) SELECT ST_Intersects((从 wardstable 中选择 the_geom,其中 gid=37), ST_GeomFromText('POINT(-87.6547884 41.96367)'));

谢谢!

I just started using PostGIS & Postgresql and everything is running smoothly for the most part. When I try to find which MULTIPOLYGON s a POINT lies in I'm getting stuck. I have two separate points that I am certain lie inside one and only one shape that is of MULTIPOLYGON data type in my database. They are not the same points and they are in different formats.

Example 1, I'm not sure what format it is but the query returns true value like I expected (note, I found this value by loading the dataset into QGIS and hovering over a point inside).

In the second example, I geocoded an address that lies inside the shape I'm looking at. However, a false value is returned as a result of the query.

I used shp2pgsql to load the data into my database directly from a shape file. The shape file's SRID is 4269 (I've tried running the queries below while specifying the SRID during the GeomFromText call but the results are the same).

What is the difference between the two coordinate sets? What do I need to do so that I can perform an intersection test using POINTS that use lat/lon values?

1.) SELECT ST_Intersects((select the_geom from wardstable where gid=37),
ST_GeomFromText('POINT(1172539 1924462)'));

2.) SELECT ST_Intersects((select the_geom from wardstable where gid=37),
ST_GeomFromText('POINT(-87.6547884 41.96367)'));

Thanks!

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

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

发布评论

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

评论(1

じее 2024-09-15 07:09:23

在执行 ST_Intersects 等空间操作时,多边形和点数据集都应位于同一投影 (SRID) 中。在第二个示例中,该点的坐标采用纬度/经度 (4326)。您应该使用 ST_Transform 将它们转换为 4269:

SELECT ST_Intersects((select the_geom from wardstable where gid=37), ST_Transform(ST_GeomFromText('POINT(-87.6547884 41.96367)',4326),4269));

编辑:我错过了 ST_GeomFromText 中的 SRID 参数。

Both the Multipolygons and the Points dataset should be in the same projection (SRID) when performing a spatial operation like ST_Intersects. In your second example the point's coordinates are in lat/lon (4326). You should transform them to 4269 using ST_Transform:

SELECT ST_Intersects((select the_geom from wardstable where gid=37), ST_Transform(ST_GeomFromText('POINT(-87.6547884 41.96367)',4326),4269));

Edit: I missed the SRID parameter in ST_GeomFromText.

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