Big fan of the sf (and previously, sp) spatial packages in R.

I see spTransform and st_transform as methods to reproject a spatial object into a new space. However, I have a case where I have a complicated spatial polygon object centered on a point. I'd love to not have to (inefficiently) recreate the spatial polygons from scratch at a new point (doing this for many census units centroids), but "recenter" the entire object iterative over each point. Any suggestions on how best to do this with sf (or worst case, going backward, sp) objects?

1 Answer 1


I do this a lot, because the constructors are very slow and you can modify the coordinates in place of a copy, but you also must update higher level properties, like the bbox so it's not recommended.

There are direct affine operators and you can do arithmetic on the geometries individually, see https://cran.r-project.org/web/packages/sf/vignettes/sf3.html#affine-transformations for more.

  • Affine operations! That's the key phrase, thanks. And I'd missed it in the vignettes. Much appreciated. Sep 3, 2018 at 18:37

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.