I have a set of SpatialDataFrames, both Lines and Polygons. I would like to find the lines/polygons where they overlap. Ultimate goal is to keep all overlaps (preferably with data included) and remove the not-overlapping polygons. The users should be able to see which polygons do overlap and can take action.
I am hoping you can give me a little push to complete this task. Thanks!
Preferably it is showed on leaflet. If that’s too difficult a dataframe with overlapping data will work too.
I have tried using st_intersection
, which gives me error ‘no applicable method for ‘st_intersection’… and using gIntersects(spgeom1, spgeom2)
which gives me results in TRUE/FALSE format. With some editing I can get the results in row (spgeom2) and col (spgeom1) format. But that’s it…
spdf1 = geojsonio::geojson_read("C:/Users/folder/json/data1.json", what = "sp")
spdf2 = geojsonio::geojson_read("C:/Users/folder/json/data2.json", what = "sp")
spdf3 = geojsonio::geojson_read("C:/Users/folder/json/data3.json", what = "sp")
sp1sp2 = gIntersect(spgeom1, spgeom2, byid = TRUE)
dfoverlaps = as.data.frame(sp1sp2)
overlaps = which(dfoverlaps == “TRUE”, arr.ind = TRUE)