Skip to content
Prev 24452 / 29559 Next

Overlay between polygons and their intersecting lines

Thank you very much for your answers!

rgeos::gRelate(Inter[1], PolyD, byid = TRUE)
# From what I undestand of the "Dimensionally Extended nine-Intersection 
Model" ( https://en.wikipedia.org/wiki/DE-9IM ),
# It looks like the green segment is in fact a bit shorter and the blue 
one starts a bit before the separation between the two polygons
# Then it makes sense (e.g. the intersection between the boundary of the 
green segment and the interior of the black polygon is the end point,
# there is no intersection between the boundaries of the green segment 
and the red polygon, ...)

"Is it possible that this relates to the scale factor of GEOS?"
# It seems so; thanks for the hint!
# Changing the scale before gIntersection() changes the outcome.
# Alternatively, we can change it before over(). Strangely, I only found 
one "good scale" for this, though I don't know how to generalize the 
result (which scale to apply when).

# Only "scale = 0.01" leads to the good result:
setScale( scale=0.01 )
#Inter1b <- gDifference( Inter[1], gBoundary(Inter[1]) )
#Inter2b <- gDifference( Inter[2], gBoundary(Inter[2]) )
over(Inter[1], PolyD, byid=T, returnList = TRUE, minDimension = 1) # OK
[[1]]
   Attribute
1    1black
over(Inter[2], PolyD, byid=T, returnList = TRUE, minDimension = 1) # OK
[[1]]
   Attribute
2      2red



# Wrong scales for the over() output:

setScale( scale=0.01 / 10 )
over(Inter[1], PolyD, byid=T, returnList = TRUE, minDimension = 1) # nothing
over(Inter[2], PolyD, byid=T, returnList = TRUE, minDimension = 1) # 2 
overlaps

setScale( scale=1 )
over(Inter[1], PolyD, byid=T, returnList = TRUE, minDimension = 1) # 2 
overlaps
over(Inter[2], PolyD, byid=T, returnList = TRUE, minDimension = 1) # OK

setScale( scale=10 )
over(Inter[1], PolyD, byid=T, returnList = TRUE, minDimension = 1) # OK
over(Inter[2], PolyD, byid=T, returnList = TRUE, minDimension = 1) # 2 
overlaps



All the best,


Gwennael



Le 28/05/2016 12:15, Edzer Pebesma a ?crit :