Home > OS >  How to place the geographical coordinates around polygon with sf?
How to place the geographical coordinates around polygon with sf?

Time:01-12

I have this folowing polygon.

library(ggplot2)
library(sf)
#> Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.1; sf_use_s2() is TRUE

poly <- st_polygon(list(rbind(
  c(-90, 70),
  c(-40, 70),
  c(-40, 74),
  c(-90, 74),
  c(-90, 70)
))) |>
  st_sfc() |>
  st_segmentize(5) |>
  st_set_crs(4326) |>
  st_as_sf() |>
  st_transform(3413) |>
  st_cast("POLYGON")

ggplot()  
  geom_sf(data = poly)  
  theme(
    panel.background = element_blank()
  )

Is it possible to place the coordinate labels in a way that they would follow the “shape” of the polygon (instead of the plotting area)?

Created on 2023-01-11 with enter image description here

  •  Tags:  
  • rsf
  • Related