如何使用Postgres找到2公里半径的左长
我有一个邮政表,其中存储为点(几何数据类型)。我有兴趣用2公里半径查询给定纬度值的所有行。另外,我希望为此有一个合适的数据类型,目前我将这些值存储为点。但是在一些调查中,我发现这里使用多边形。但是,即使我无法实现结果。
任何一点都可以用合适的GTS功能来实现确切的查询
I have a postgres table with lat-long values stored as point (Geometric data type). I am interested to query all rows with 2km radius for the given lat-long values. Also, I am expecting for a suitable datatype for this, currently I stored these values as POINT. But on some investigation, I found to use POLYGON here. But even though I couldn't able to achieve the results what expected.
Can any one point me the exact query with suitable GTS functions to achieve this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
https://postgis.net/works.net/workshops/workshops/postgis-postgis-inpostgis-intro/spatial_ial_ial_relatial_htial_htriphatss.htriphatss.htriationss.hthtphipss.htriationss.html
示例说明:
https://postgis.net/workshops/postgis-intro/spatial_relationships.html
example explanation:
要查询某个半径内的几何形状,您可能想使用
st_dwithin
。为了将其与米一起使用,您必须使用具有仪表单位的SRS,例如
epsg:26918在
类型,例如
polygon
或linestring
,您可能想使用st_geogfromtext
而不是st_makepoint
:请记住,请记住转换的转换几何不仅仅是改变其srid -check
st_transform
。进一步阅读
将所有建筑物从指定的坐标
PostGis的情况如何处理使用不同SRID
发送的坐标To query geometries within a certain radius you might wanna use
ST_DWithin
. In order to use it with metres you have to either use a SRS that has metre as unit, such asEPSG:26918
, or usegeography
instead ofgeometry
:In case you're dealing with different geometry types, such as
polygon
orlinestring
, you might wanna useST_GeogFromText
instead ofST_MakePoint
:Keep in mind that transforming a geometry is much more than just change its SRID - check
ST_Transform
.Further reading
Getting all Buildings in range of 5 miles from specified coordinates
How is postgis treating coordinates sent with different SRID