Data available here
I have 2 large sf objects. One is an sf polygon object of buffered points and the other is an sf line object. I would like to difference the line object using the polygon object like so:
library(sf)
geopackage = 'differenceBIG.gpkg'
lines <- st_read(geopackage , layer = "lines")
points <- st_read(geopackage , layer = "points")
poly <- st_buffer(points, dist = 0.001)
differenced <- st_difference(lines, poly)
This take more than 3 days to complete (I gave up waiting); not good enough. Is there a way of differencing these large sf objects in a much shorter time? I'm using a PC with i7-6700 CPU @ 3.4 GHz and 32 GB of RAM.
Update: Turns out st_difference isn't the same as Difference in QGIS. I found the following in the sf.pdf document
# A helper function that erases all of y from x:
st_erase = function(x, y) st_difference(x, st_union(st_combine(y)))
differenced <- st_erase(lines, poly)