给定Postgis上的X值,找到线串中插值点的Y值 [英] Find Y value of an interpolated point in a Linestring given an X value on Postgis

查看:94
本文介绍了给定Postgis上的X值,找到线串中插值点的Y值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在给定X时找到Linestring内插点的Y值的最佳方法是什么.

I would like to know what's the best way to find the Y value of an interpolated point inside the Linestring, when given the X.

我的输入LinestringX坐标将始终是增量且非顺序的(如下例所示). Y值可以是任何实数.

The X coordinates of my input Linestring will always be incremental and non sequential (as in the example below). The Y values could be any real number.

LINESTRING(223 -59,228 -59.3,233 -59.7,242 -60,263 -60.4,
           268 -61.7,275 -62.1,280 -62.5)

给出一个X值(例如270),查询将在Linestring内部输出插值值(在这种情况下,将使用点[268 -61.7][275 -62.1]输出-61.81428571) >用于插值)

Given an X value (let's say 270 for example), the query would output the interpolated value inside the Linestring (in this case it would be -61.81428571, using points [268 -61.7] and [275 -62.1] for the interpolation)

如果X值已经属于Linestring,则它将仅输出其相应的Y值. 268: -61.7

If the X value already belongs to the Linestring, the it would just output its corresponding Y value. 268: -61.7

输入表将只有一列和一行带有线串的行. X值将是查询的一部分.

The input table will just have a single column with a single row with the linestring. The X value would be part of the query.

我正在使用PostGIS.

I'm using PostGIS.

推荐答案

可能最简单的方法是生成一条垂直线并检查它与几何之间的交点.确保线与线串的边界框一样长是很好的.

Probably the easiest way will be to generate a vertical line and check intersection between it and the geom. It will be good to make sure the line is as long as the bounding box of the linestring.

SELECT ST_INTERSECTION(geom, ST_MakeLine(ST_MakePoint(268, ST_YMin(geom)), ST_MakePoint(268,ST_YMax(geom)))) 
FROM
    linestrings;

这篇关于给定Postgis上的X值,找到线串中插值点的Y值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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