How can I divide the multiple overlapping polygons into multiple non-overlapping polygons? Here is an example: I would like to divide the long yellow polygon in the image into 3 polygons based on where it touches the other two.


seine_buff_5km = st_buffer(seine, dist = 5000)

tm_shape(seine_buff_5km) +
  tm_fill( col = "name", alpha =.5) +
tm_shape(seine) +


Of course, I would like to do that for a larger data set with many more polygons. I guess one way to do it is subtract all polygons in an sf object from each other.


st_intersection on a single object will chop it into non-overlapping parts:

> bi = st_intersection(seine_buff_5km)
> bi
Simple feature collection with 5 features and 3 fields
geometry type:  GEOMETRY
dimension:      XY
bbox:           xmin: 513345.8 ymin: 6655432 xmax: 884953.8 ymax: 6943863
epsg (SRID):    2154
proj4string:    +proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
   name                       geometry n.overlaps origins
1 Marne POLYGON ((658951.7 6862882,...          1       1
2 Marne POLYGON ((657550.3 6852588,...          2    1, 2
3 Seine POLYGON ((517155.1 6930721,...          1       2
4 Seine POLYGON ((695195.4 6815345,...          2    2, 3
5 Yonne MULTIPOLYGON (((711168.3 68...          1       3

The origins column is a "list-column" that shows which of the original parts form the new part. When plotted in unique colours the five parts look like this:

enter image description here

Note how the green part is treated as a single object because it isn't quite cut into parts by the other polygons.

The fifth row (blue polygon, Yonne), is shown as a MULTIPOLYGON because there is a tiny sliver cut off above the orange polygon.

  • Thank you very much! Perhaps there is a way to divide the lines by where they touch and then buffer them? – S Front Feb 11 '19 at 11:43
  • That sounds like you really have a different question... what is it you want to achieve? – Spacedman Feb 11 '19 at 11:45
  • Well I would like to divide the above polygons into six polygons based on where the lines or the polygons touch. I am not primarily interested in the yellow and the orange intersection. Sorry if I am not clear. – S Front Feb 11 '19 at 11:58
  • I don't see how you get six polygons. Do you really want to get five line segments from the three line features in the original seine object? – Spacedman Feb 11 '19 at 12:29
  • Yes, exactly divided by where they touch. The original dataset contains of buffers around country borders. I thought that with a solution to this simple example, I could then solve the task for country borders so that I have a buffer for each unique two contiguous states. – S Front Feb 11 '19 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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