[postgis-users] How to match lines between two similar graphs?

Matej Mailing mailing at tam.si
Thu Jan 26 06:42:46 PST 2012


Hi,

I am having somehow similar issue: I have a (single) table with the
lines that represent cables on the ground. Those cables sometimes
cross, sometimes they go in the same direction in some distance
between them, sometimes one on another and my goal is to get the
trenches (that are wide for example 1 meter) that would include the
cables. So basically if the cables are for 1 meter apart from each
other (no matter if they cross, lie on on another or go into the same
direction) within this radius, the result should be one line
representing them. If they are more far apart, another line would
represent that line (another trench would have to be dig).

Some guys posted ST_SharedPath(geom1, ST_Snap(geom1, geom2, radius))
as a possible solution, but I can't seem to get it to work properly in
PostGIS 2.0. I get just one result set - could it be because both
geometries are the same (same table).

Being not so fluent in PostGIS this is really driving me nuts and
would appreciate any help. I could also post some sample SHP data if
anyone would be so nice to look at it.

Thanks,
Matej

2012/1/26 Stephen Woodbridge <woodbri at swoodbridge.com>:
> Hi All,
>
> I have an interesting problem I am trying to solve and would love some
> feedback on how to best go about it.
>
> I have road data from two different vendor data sets. But this could also be
> one road network and a GPS track, so I think this is a pretty common use
> case.
>
> Assumptions:
>
> o the networks are similar, ie: they have similar roadway coverage
> o the two sets might be slightly misaligned, ie: shifted by some amount
> o the segments in the two data sets do not have to be broken into equivalent
> segments, ie: one segment in A might be represented my multiple segments in
> B
> o segments are not aligned end point wise, ie: a segment in A might go from
> mid-point one segment in B to the midpoint of a connected segment in B
> o in many cases I will be working with a set of lines in one set that I need
> to match to the other to select a matching set of lines.
>
> So strategies for matching these:
>
> 1. take a segment from A and buffer it, then intersect the data in B and
> select the longest intersected object. I can probably throw out any pieces
> smaller than the buffer distance.
>
> 2. Do the same but buffer and union the set of lines into a single
> multipolygon, and intersect that with the other set.
>
> 3. ??? Other ideas?
>
> Thoughts on performance?
>
> Typically I will have a small set (1-20) of segments to compare against a
> larger (100K-2M) set. Obvious a spatial index will will be used. But I'm
> wondering what is the fast way to do this matching computationally. I think
> I will want to be able to compare 1-200 sets like this every 5 mins as data
> comes in from a feed, while supporting other queries.
>
> Thoughts would be appreciated.
>
> -Steve
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list