1

I would like to erase the elements of A, a SpatialLinesDataFrame, that overlap with B, another SpatialLinesDataFrame to give A' which should be smaller than A. In other words I want a new SLDF that does NOT overlap at all with B. This is essentially the "erase" function in ArcMap. To be clear I do not want to keep the instances where they overlap, I want to eliminate the overlapping instances from A so that A' and B have no overlap.

Thanks!

wraymond
  • 295
  • 1
  • 6
  • 17
  • Explain what you mean by "overlap." Do you want to eliminate all elements of A inside the convex hull of B? – Tbar May 06 '17 at 04:58
  • A and B are spatial lines so if the lines overlap/occupy the same space. i.e. part of A "overlaps" with part of B – wraymond May 06 '17 at 05:52
  • I'm not trying to be dense here, but I really don't know what you mean. It's not clear how you would define the "overlap" of a bunch of 1-dimensional lines... Do you have a picture that can illustrate what you mean? – Tbar May 06 '17 at 06:08
  • The lines are two dimensional, as they are SpatialLinesDataFrames. Here is the simplified version. Line A runs from 0 to 5, line B runs from 4 to 8. I want a function that subtracts the overlap (4 to 5) from A so that A' run from 0 to 4. Does that help? Thanks for your dedication. – wraymond May 06 '17 at 16:57

1 Answers1

0

Try using rgeos::gDifference on your A and B objects, potentially after doing a rgeos::gUnaryUnion on B.

Edzer Pebesma
  • 3,814
  • 16
  • 26