简体   繁体   English

如何使用ST_DWithin查找近点?

[英]How to use ST_DWithin to find near point?

This is the first time I create a GIS query. 这是我第一次创建GIS查询。 In one table of my database, there is a column with point type. 在我的数据库的一个表中,有一个点类型的列。 Each record is one ATM machine. 每条记录都是一台ATM机。 I want to write a query to get ATM machines that near by my location within 1km range.How to use ST_DWithin in SQL query to find record? 我想编写一个查询来获取我的位置在1km范围内附近的ATM机。如何在SQL查询中使用ST_DWithin来查找记录?

SELECT *
  FROM atm_finder
  WHERE ST_Distance(ST_Transform(ST_GeomFromText('POINT([Lon] [Lat])',4326),26986),ST_Transform(location,26986)) <= 1000

Where [Lon] & [Lat] - GPS coordinates of the point. 其中[Lon]和[Lat] - 点的GPS坐标。 But so far as you used POINT type at first use: 但是,首先使用POINT类型:

SELECT AddGeometryColumn('atm_finder', 'location', 4326, 'POINT', 2);

Of course before that you should rename the field 'location' (in order to not lose the data) and fill the new one with this data. 当然,在此之前,您应该重命名字段“location”(以便不丢失数据)并使用此数据填充新字段。

I don't see well how ST_DWithin could be used with two points... 我不太清楚ST_DWithin如何用两点......

Something like that . 这样的事情。

select atm.id
from atm_finder atm
where ST_Distance(<your location>, atm.location) <= 1000 

//1000 = meters, works fine with geography types
//have to check your projection with geometry types

The way your table is created looks strange to me, by the way... 顺便说一下,创建表格的方式对我来说很奇怪......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BigQuery ST_DWITHIN 多点与多点 - BigQuery ST_DWITHIN multiple points with multiple points 按结果出现的半径数将结果按ST_DWith排序 - Rank order ST_DWithin results by the number of radii a result appears in Postgis ST_DWithin匹配特定半径AND右边的点 - Postgis ST_DWithin match a certain radius AND points on the right 为什么 PostGIS 将所有点堆叠在一起? (使用 ST_DWithin 查找半径 1000m 内的所有结果) - Why is PostGIS stacking all points on top of each other? (Using ST_DWithin to find all results within 1000m radius) 使用填充有PostGIS WKB坐标的Postgres array []会导致“函数st_dwithin(文本,几何,整数)不是唯一的” - Using a Postgres array[] filled with PostGIS WKB coordinates results in “function st_dwithin(text, geometry, integer) is not unique” 基于st_dwithin条件的BigQuery Left Join就像一个内部联接 - BigQuery Left Join based on st_dwithin condition acting like an Inner Join 如何使用 ST_Distance 获取靠近 POSTGIS 的地点 - How to use ST_Distance to get places near POSTGIS 这个ST_CONTAINS语句PostGIS有什么问题-多边形中的查找点 - What is wrong with this ST_CONTAINS statement PostGIS - Find point in polygon 如何在oracle中找到附近的exp产品 - How to find near exp products in oracle 如何在 BigQuery 中使用 ST_UNION - How to use ST_UNION in BigQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM