Skip to content

Data from intersecting Lines of shp files

2 messages · Barry Rowlingson, Roger Bivand

#
On Thu, Jul 11, 2013 at 1:27 PM, Tscheikner-Gratl, Franz
<Franz.Tscheikner-Gratl at uibk.ac.at> wrote:
That's a bit clearer - if you could make a simple example shapefile
that shows the problem (you don't have to share all your data) I'm
pretty sure its just a case of selecting the pipe features and looping
over one of the intersection functions, which should return the  The
problem is if you have more than one labelled pipe crossing an
unlabelled pipe, or if no pipes cross - or in that case do you want
the nearest pipe? Maybe nearest is a better solution in any case
(since crossing pipes have distance zero)...

 Worst case scenario is a double loop over features with missing data
over features with data...

Barry
#
On Thu, 11 Jul 2013, Barry Rowlingson wrote:

            
Maybe gTouches() rather than gIntersects() as maybe the contiguous pipe 
segments to segments with NA attribute values can by listed, while I'm not 
sure whether they intersect:

library(rgeos)
l1 = readWKT("LINESTRING(0 0,2 2)")
l2 = readWKT("LINESTRING(1 1,2 0)")
gTouches(l1,l2)
gIntersects(l1,l2)

so they do touch and intersect. I would suggest identifying the NA 
attribute Lines objects first, then loop over them to find their 
contiguous neighbours. If there are two neighbbours, and the value of 
interest is identical, it may be copied across, if different, or for three 
or more with different values, manual intervention may be needed, unless 
there is some other non-NA variable indicating which bit of the jigsaw 
puzzle belongs where.

Roger