0

I am struggling to find a systematic way to convert coordinates and geometries to km. Let's say I have a .shp file, which I read with st_read. I want to draw a circle of radius 10 kms around a city. I know the coordinates of the city in latitude and longitude, so I can convert to km with:

  y = 111.2 * latitude
  x = 111.2 * longitude * cos(pi / 130* latitude)

And then define a circle centered in x,y. Now I can easily draw the circle with plot.owin {spatstat.geom}, but, how can I plot is onto the geometry of the .shp file? Can I use st_crs to set the coordinates of the circle to the reference system of the original map (and how)?

altroware
  • 940
  • 3
  • 13
  • 22
  • 3
    If you just need circles around points, `sf::st_buffer()` should work. The edges can be a bit ragged, but there is a `terra` workaround here: https://stackoverflow.com/a/73506577/7547327 – mrhellmann Nov 15 '22 at 01:38
  • Awesome, thank you. Can I set the units in `sf::st_buffer()`, say km or meters? – altroware Dec 15 '22 at 17:19
  • You can use the `units` package, or set the crs to one with the correct units for the area of the globe. – mrhellmann Dec 15 '22 at 19:12

0 Answers0