1

I'm looking for a solution that will let me add a 100m buffer around 2 million points and then dissolve/union that output into a single multipart polygon.

On a much smaller scale (100 points) using R I can do this:

library(sf)
bbox <- st_sfc(st_polygon(list(rbind(c(0,0),c(90,0),c(90,90),c(0,90),c(0,0)))), crs = st_crs(27700))
points <- st_sample(bbox,100)
buffer <- st_buffer(points,5)
union <- st_union(buffer)

However, I know this will not scale well.

Are there any solutions using any tool (preferably something that is free) that could run this type of operation on a laptop with 20GB RAM without crashing or taking days to complete?

2 Answers 2

2

If you really mean a buffer of every single point, I'd make a copy of a boilerplate circle polygon at 0,0 and then update its geometry by translation (there are Arith methods for affine transformation, we only need "+").

This runs in a few minutes. I haven't tried 2e6. Please try with a small sample of your own data first.

 pts <- matrix(rnorm(2e6), ncol = 2)
 buf <-  0.1
 library(sf)
 p <- st_buffer(st_point(cbind(0, 0)), buf)
 ## copy the poly
 l <- replicate(nrow(pts), p, simplify = FALSE)
 for (i in seq_len(nrow(pts))) {
  l[[i]] <- l[[i]] + pts[i, ]
 }
 x <- st_union(st_sfc(l))
2
  • About 300s for 1e6 points, the union I can't vouch for , you might want to chunk and reduce that one. Good luck
    – mdsumner
    May 28, 2020 at 3:49
  • 1
    Thanks. For 1.3 million points with the union it took 35 minutes.
    – Chris
    May 28, 2020 at 21:42
1

When you are buffering above you get a (circle) polygon buffer for every point, is that what you want?

Is the convex hull sufficient? No problem with 2e6 points.

pts <- matrix(rnorm(4e6), ncol  = 2L)
idx <- chull(pts)  # convex hull
## hull as POLYGON
p <- sf::st_polygon(list(pts[c(idx, idx[1]), ]))
sf::st_buffer(p, 1)

(I would never ever create sf POINT with that many coordinates, it's wildly inefficient to explode simple x/y vectors into lists of pairs and I do everything I can to avoid it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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