ST_DWithin以度为参数,而不是以米为单位,为什么? [英] ST_DWithin takes parameter as degree , not meters , why?

查看:1291
本文介绍了ST_DWithin以度为参数,而不是以米为单位,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ST_DWithin 文件说,第三个参数(距离)以米为单位.但是,当我执行一些查询时,似乎将第三个参数作为学位"?

The ST_DWithin document says , the third parameter(distance) is in meters. But when I execute some query , it seems it takes the 3rd parameter as 'degree' ?

这是我的简化表结构:

> \d+ theuser;
                         Table "public.theuser"
  Column  |          Type          | Modifiers | Storage  | Description 
----------+------------------------+-----------+----------+-------------
 id       | bigint                 | not null  | plain    | 
 point    | geometry               |           | main     | 
Indexes:
    "theuser_pkey" PRIMARY KEY, btree (id)
    "point_index" gist (point)
Referenced by:
    ...
Has OIDs: no

所有点都以SRID = 4326存储.

All points are stored with SRID=4326.

这是查询:

> select * from theuser where ST_DWithin(point , ST_GeomFromText('POINT(120.9982 24.788)',4326) , 100 );

它将第三个参数(100)作为'degree',因此它返回所有数据,我必须缩小到0.001才能找到附近的点.

It takes the 3rd parameter (100) as 'degree' , so it returns all data , I have to narrow down to 0.001 to find nearby points.

但是我如何直接将电表作为第三个参数(我不想进行电表/度数转换)?我的查询出了什么问题?为什么postgreSQL不能将其视为文档所说的计量器?

But how do I directly pass meters as 3rd parameter (I don't want to do meter/degree transformation ) ? What's wrong with my query ? why postgreSQL doesn't take it as meters as document says ?

环境:

> select version();
                                                  version                                                  
-----------------------------------------------------------------------------------------------------------
 PostgreSQL 8.4.9 on i486-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3, 32-bit

> SELECT postgis_lib_version();
 postgis_lib_version 
---------------------
 1.4.0

如果是导致此问题的SRID,则哪个SRID直接使用表"作为单位? (我尝试过转换为SRID = 2163,但仍在度数上).

If it is the SRID that causes this problem , what SRID directly makes use of 'meter' as the unit ? (I tried transforming to SRID=2163 , but still in degree) Thanks.

推荐答案

来自 docs :

对于几何图形:距离以由 几何空间参考系统.

For Geometries: The distance is specified in units defined by the spatial reference system of the geometries.

如果您的数据使用SRID = 4326,则您指定的距离以度为单位.

If your data is in SRID=4326 the distance you are specifying is in degrees.

您要么必须使用 ST_Transform 和基于仪表的坐标系,要么是两个功能: ST_Distance_Sphere (更快,更不准确)或

You either have to use ST_Transform and meter based coordinate system, or one of the two functions: ST_Distance_Sphere (faster, less accurate) or ST_Distance_Spheroid.

这篇关于ST_DWithin以度为参数,而不是以米为单位,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆