Geospatial Stuff
University of Auckland
get_hemisphere <- function(central_meridian = 0, density = 1) {
lons <- c( 1, 1, -1, -1, 1) * 90 + central_meridian
lats <- c(-1, 1, 1, -1, -1) * 90
st_polygon(list(matrix(c(lons, lats), ncol = 2))) |>
st_sfc() |>
as.data.frame() |>
st_as_sf(crs = 4326) |>
smoothr::densify(density)
}
hemi_w <- get_hemisphere(-90)
hemi_e <- get_hemisphere(90)
world_w <- World |>
st_intersection(hemi_w) |>
mutate(geometry = geometry * matrix(c(-1, 0, 0, 1), 2, 2)) |>
st_set_crs(4326)
world_e <- World |>
st_intersection(hemi_e)
world_abs <- world_w |>
bind_rows(world_e) |>
mutate(id = 1) |>
group_by(id) |>
summarise() |>
mutate(geometry = geometry - c(90, 0)) |>
st_set_crs(4326) |>
st_transform("+proj=eqearth")greenland <- World |>
filter(name == "Greenland") |>
st_transform("+proj=merc") |>
mutate(geometry =
(geometry + c(2e6, -3.1e6)) * diag(1, 2, 2) * 0.85) |>
st_set_crs("+proj=merc")
greenland_buffer <- greenland |>
st_buffer(1e5)
w <- World |>
st_transform("+proj=moll") |>
st_make_valid() |>
st_set_crs("+proj=merc") |>
st_difference(greenland_buffer) |>
bind_rows(greenland)August 2026 - GeoCart - Wellington