Skip to content
Prev 18799 / 29559 Next

Data from intersecting Lines of shp files

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