Loop to check multiple polygons overlap in r

المشرف العام

Administrator
طاقم الإدارة
I have a set of polygons (available here: http://ulozto.cz/x39ELbFt/polygons-zip) created in QGis and processed in R. I would like to know if they are overlapping or not, and if yes, where is the overlapped area (and between which polygons)? I know that to figure this out I can use tools:


  • over{sp} - return data.frame not a spatial object!
  • intersect{raster}
  • gIntersection{rgeos}
I can find intersection by comparing 1 by 1 polygon each time step. However as my real data are huge, I prefer to make a loop and include the iteration of polygons:


  • intersect(p1, p2)
  • intersect(p1, p3)
  • intersect(p1, p4)
  • intersect(p2, p3)
  • etc...
For the moment, I made up only loop for one polygon intersecting another 3. From resulting list of overlapping polygons I can't however really say which polygons are overlapped. And if they are not (p1 and p4) this NULL value is not included in my resulting list!

Any suggestion will be highly appreciated

library(sp) library(raster) library(rgeos) library(spatstat) library(rgdal) setwd("D:/...") p1
 
أعلى