Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active August 7, 2026 01:47
Show Gist options
  • Select an option

  • Save mdsumner/cd3669c6dbc3afe8aafa9607f7b6f2d5 to your computer and use it in GitHub Desktop.

Select an option

Save mdsumner/cd3669c6dbc3afe8aafa9607f7b6f2d5 to your computer and use it in GitHub Desktop.
# dsn <- sds::nsidc_seaice()
# library(terra)
# plot(rast(dsn))
#e <- draw()
#dput(round(as.vector(e)))
## pole inside extent, south polar steregraphic
e <- c(xmin = -1094338, xmax = 1230070, ymin = -699223, ymax = 997424)
xyedge <- vaster::vaster_boundary(c(64, 64), e)
## reproj_extent infills the source extent to not miss the pole
vaster::plot_extent(reproj::reproj_extent(e, "EPSG:4326", source = "EPSG:3031"), asp = "")
lines(reproj::reproj_xy(xyedge, "EPSG:4326", source = "EPSG:3031"), lty = 2)

## terra vect/project has the same problem but rast/project does the job
library(terra)
#> terra 1.9.41
plot(ext(project(rast(ext(xyedge), ncols = 64, nrows = 64, crs = "EPSG:3031"), "EPSG:4326")))

plot(project(vect(xyedge, "poly", crs = "EPSG:3031"), "EPSG:4326"), add = TRUE, lty = 2)

Created on 2026-08-07 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment