计算点距离50英里(北,东北45%,西南45%) [英] Caculate point 50 miles away (North, 45% NE, 45% SW)

查看:84
本文介绍了计算点距离50英里(北,东北45%,西南45%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PostGIS中,有没有一种方法可以计算出50英里外的不同方向上的另一个点?

In PostGIS, Is there a way to calculate another point 50 miles away in different directions?

给出一个点(纽约",-74.00,40.71),我该如何计算以下点?

Given a point, ('New York',-74.00,40.71), how do I calculate the following points?

1) 50 miles directly North
2) 50 miles 45% North East
4) 50 miles directly East
3) 50 miles 45% South West

更新: 似乎 http://postgis.net/docs/ST_Project.html 可能是解决方案.

Update: It seems http://postgis.net/docs/ST_Project.html may be the solution.

ST_Project('POINT(-74.00 40.71)'::geography, 80467.2, radians(45.0))

但是,我需要参考数据库记录来做到这一点.而不是硬编码.

However, I need to reference the database record to do it. not hard code it.

推荐答案

尝试结合 ST_Project CTE 的a>-调整到所需的方位角.

Try combining ST_Project with a CTE - adjust the values of radians to the azimuth you need.

WITH j AS (
  SELECT poi::geography AS poi FROM t
)
SELECT 
  ST_AsText(ST_Project(j.poi, 80467.2, radians(90.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(45.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(180.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(135.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(270.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(225.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(360.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(315.0)),2)
FROM j;

      st_astext      |      st_astext      |    st_astext     |     st_astext      |      st_astext      |     st_astext      |    st_astext     |      st_astext      
---------------------+---------------------+------------------+--------------------+---------------------+--------------------+------------------+---------------------
 POINT(-73.05 40.71) | POINT(-73.32 41.22) | POINT(-74 39.99) | POINT(-73.33 40.2) | POINT(-74.95 40.71) | POINT(-74.67 40.2) | POINT(-74 41.43) | POINT(-74.68 41.22)
(1 Zeile)

注意:图像中的缓冲区仅用于说明.

Note: The buffer in the image is just for illustration.

这篇关于计算点距离50英里(北,东北45%,西南45%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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