[postgis-users] A function for associating geographical objects
Marcin Mionskowski
mionskowskimarcin at gmail.com
Thu Aug 31 07:22:12 PDT 2023
Don't know, if I understood you well, but maybe you are looking for
something like this (associates lines to points based on the smallest
distance; if you want it the other way around (points to lines) just
replace t1 with t2 inside DISTINCT ON clause):
with
t as ( --making test dataset
select gs
,ST_MakePoint(random()*10,random()*10) as p
,ST_MakeLine(ST_MakePoint(random()*10,random()*10),ST_MakePoint(random()*10,
random()*10)) as l
from generate_series(1,100) gs
)
select distinct on (t1.gs)
t1.gs
,t2.gs
,ST_Distance(t1.p,t2.l) dist
from t t1
, t t2
order by t1.gs,dist
czw., 31 sie 2023 o 15:11 William Roper <roper.william at gmail.com>
napisał(a):
> ST_DumpPoints [1] perhaps?
>
> [1] https://postgis.net/docs/en/ST_DumpPoints.html
>
> On Thu, 31 Aug 2023 at 13:52, Shaozhong SHI <shishaozhong at gmail.com>
> wrote:
>
>> In a geospatial dataset, there are numerous objects. Some points must be
>> associated with a line. Do we have a function to check out?
>> Regards,
>> David
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20230831/49b4ec8f/attachment.htm>
More information about the postgis-users
mailing list