You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
845 B
24 lines
845 B
lons = seq(-180, 180, by = 30)
|
|
lats = seq(-90, 90, by = 30)
|
|
|
|
grat = st_graticule(lon = lons, lat = lats)
|
|
|
|
box = st_bbox(c(xmin = -180, xmax = 180,
|
|
ymax = 90, ymin = -90),
|
|
crs = st_crs(4326)) |>
|
|
st_as_sfc() |>
|
|
smoothr::densify(max_distance = 1)
|
|
|
|
degree_labels = function(grat, vjust, hjust, size, lon = T, lat = T) {
|
|
pts = grat |>
|
|
st_cast('POINT') |>
|
|
group_by(degree, type, degree_label) |>
|
|
filter(row_number() == 1)
|
|
|
|
list(
|
|
if (lon) geom_sf_text(data = filter(pts, type == 'E'), vjust = vjust, size = size,
|
|
mapping = aes(label = degree_label), parse = TRUE),
|
|
if (lat) geom_sf_text(data = filter(pts, type == 'N'), hjust = hjust, size = size,
|
|
mapping = aes(label = degree_label), parse = TRUE)
|
|
)
|
|
} |