Open lambdamoses opened 3 months ago
Thanks for the interesting benchmarks; most of this is well known though. I do consider (but do not promise) to work on the points-only case (see e.g. the pointx branch) within the next 12 months, but it is unlikely that I will work on fixing this for mixed geometries. I will take well written and maintainable PRs seriously. Adding a dependency is unlikely, given that this package has a high maintenance cost (many reverse dependencies + complex & dynamic upstream system requirements).
Based on profiling, it's slow for a large number of geometries because of the
mapply
here: https://github.com/r-spatial/sf/blob/cfc321aa33633017274d6832589021417e21e700/R/arith.R#L152-L163 That's an R loop, but it would be nice to push it into C++. Here's a reprex:It's way faster to get the coordinates, apply the affine transformation, and reconstruct the sf.
Also faster to do the transformation on the coordinates and reconstructing the sf with
sfheaders
for polygons, though not sure if you want to introduce a dependency. Plus forsfheaders
, the coordinates data frame must be sorted by the geometry ID. However, while it's faster, it also uses more memory.The slow part is because of the number of geometries rather than the number of vertices. It's much faster when I group the 20,000 points in the toy example into 500 MULTIPOINT geometries, but still calling
sfheaders
is so much faster.