1

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)
Josh J
  • 395
  • 1
  • 3
  • 13
  • Unable to reproduce. It took less than a minute on my machine. I'm guessing you have insufficient memory and were paging out to "virtual memory" on disk. Buy more memory. – IRTFM Feb 19 '19 at 17:20
  • That was just a sample dataset. Full size dataset uploaded. – Josh J Feb 20 '19 at 09:01

0 Answers0