1

I have two shapefiles with more than 1000 polygons each, and they represent two types of agricultural fields in the same area, which means they should be different types.

Some of the polygons are partly or completely overlapped - what I want to do is to delete those polygons - from both shapefiles - that are overlapped. Are there any methods for doing this in R using pachage sf or rgdal?

closed as unclear what you're asking by Spacedman, LaughU, whyzar, nmtoken, Kadir Şahbaz Jul 9 at 9:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Clarification needed. You have two shapefiles, call them A and B. You want to create two new shapefiles, A' and B' where A' is the set of all features from A that do not touch or overlap or intersect any features in B, and where B' is similar for features in B not overlapping any features in A? Or is there a possibility of features in A overlapping with other features in A? – Spacedman Jul 7 at 19:18
5

Given two sets of features A and B coloured red and blue:

overlaps

Then select only those from A that don't overlap any B and vice versa:

> Adash = A[lengths(st_intersects(A,B))==0,]
> Bdash = B[lengths(st_intersects(B,A))==0,]

this works by virtue of the element of the intersection list having zero-length when a feature has no intersections.

When plotted:

nonoverlaps

Not the answer you're looking for? Browse other questions tagged or ask your own question.