[postgis-users] How to check if two linestring are near to each other

Rémi Cura remi.cura at gmail.com
Mon Apr 14 00:36:19 PDT 2014


Hey,
I'm not so sure Hausdorff distance is what you want.
It measure how similar 2 shapes are, yet you could have two very similar
parts of a road network that are very far away.
In you case you are trying to express both lines that are close to each
other __and__ that are similar in shape.

Of course the obvious (but painfull) way to go would be to use postgis
topology with the tolerance set to your GPS error (+ width of the road).
This way close path would be merged automatically.

Cheers,
Rémi-C


2014-04-13 23:56 GMT+02:00 Raghavan Krishnasamylakshmanaperumal <
rkrish20 at uic.edu>:

> Hi Åsmund,
>
> Thanks for suggesting ST_HausdorffDistance, I tried this function
> directly on the database using sql query and it looks like solving my
> problem.
>
> Are these functions ST_HausdorffDistance/ST_Distance available as java
> APIs? I am trying to use org.postgis(postgis-jdbc-1.3.1.jar) library but
> not sure how to access the above mentioned functions using java. Please
> suggest me which package to look into to make use of these functions
> programmatically?
>
> Thanks in advance.
>
> -Raghavan
>
>
> On Sun, Apr 13, 2014 at 1:45 PM, Åsmund Tokheim <asmundto at gmail.com>wrote:
>
>> Hi
>>
>> I think you should be able to use hausdorff distance
>> http://postgis.net/docs/ST_HausdorffDistance.html to recognize that the
>> green, red and blue lines in your image are all similar. This method will
>> fail to recognize shared portions of a path (e.g. if the blue line at some
>> point diverges from the red and green line), but I'm not sure if this is a
>> requirement for your task
>>
>> Åsmund
>>
>>
>> On Sat, Apr 12, 2014 at 9:41 PM, Raghavan Krishnasamylakshmanaperumal <
>> rkrish20 at uic.edu> wrote:
>>
>>> Hi,
>>>
>>> I have formed a graph using my GPS traces of running/biking activities
>>> in which I have many edges representing the same path. For example every
>>> time I run from node-A to node-B my GPS traces are noted close to each
>>> other like the red,green,blue lines in the attached image. Actually those 3
>>> lines are same(representing the same path), so I want to detect such
>>> linestrings automatically and keep only one linestring and ignore others.
>>> Is there any way in PostGIS which can help me to detect the
>>> nearness/closeness of the linestrings?
>>>
>>> --
>>> Thanks and Regards,
>>> Raghavan KL
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at lists.osgeo.org
>>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>>>
>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>>
>
>
>
> --
> Thanks and Regards,
> Raghavan KL
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140414/b1e22926/attachment.html>


More information about the postgis-users mailing list