Skip to content

Instantly share code, notes, and snippets.

@szechno
Created November 22, 2025 19:43
Show Gist options
  • Select an option

  • Save szechno/d1826609f4fd9162dbff5b16050346ff to your computer and use it in GitHub Desktop.

Select an option

Save szechno/d1826609f4fd9162dbff5b16050346ff to your computer and use it in GitHub Desktop.
library(rnaturalearth)
library(rnaturalearthdata)
library(mapgl)
library(mapview)
library(sf)
library(dplyr)
antartic10 <- ne_download(scale = 50, type = 'antarctic_ice_shelves_polys',
category = 'physical')
antartic10l <- ne_download(scale = 50, type = 'antarctic_ice_shelves_lines',
category = 'physical')
# create polygon representing "WGS 84 / Antarctic Polar Stereographic EPSG:3031"
bb <- st_polygon(x = list(
matrix(
c(
-180.0, -90.0,
180, -90,
180, -60,
-180, -60,
-180, -90),
ncol=2,
byrow=TRUE)
)
) |>
st_sfc(crs = 4326) |>
st_as_sf()
# need attributes to work in mapboxgl
bb$name <- "WGS 84 / Antarctic Polar Stereographic EPSG:3031"
mapboxgl_view(bb)
# https://en.wikipedia.org/wiki/South_Pole
# South Geographic Pole
south_pole_1 <- st_point(x = c(0, -85)) |> st_sfc(crs = 4326) |>
st_as_sf()
south_pole_1$name <- "South Geographic Pole"
maplibre_view(south_pole_1)
mapview(south_pole_1)
# South Magnetic Pole (2020)
south_pole_2 <- st_point(x = c(135.866, -64.081)) |> st_sfc(crs = 4326) |>
st_as_sf()
maplibre(style = carto_style("voyager"),
projection = "globe") |>
fit_bounds(antartic10) |>
add_fill_layer(id = "EPSG:3031",
source = bb,
fill_opacity = 0.5,
fill_color = "lightgrey"
) |>
add_fill_layer(id = "glaciated areas",
source = glacial,
fill_color = "scalerank") |>
add_fill_layer(id = "polys",
source = antartic10,
fill_color = "orange") |>
add_line_layer(id = "lines",
source = antartic10l,
line_color = "red",
line_width = 3) |>
add_circle_layer(id = "South Geographic Pole",
source = south_pole_1,
circle_color = "lightblue") |>
add_circle_layer(id = "South Magnetic Pole (2020)",
source = south_pole_2,
circle_color = "navy") |>
add_legend(legend_title = "Antarctic Ice Shelves",
type = "categorical",
values = c("Ice shelf collapses",
"Ice shelf previous extent",
"Antarctic Polar Stereographic",
"Almost the South Pole (0, -85)",
"South Magnetic Pole (2020)"),
colors = c("orange", "red", "lightgrey", "lightblue", "navy"),
style = list(
background_opacity = 0.95,
background_color = "#2E8B57",
text_color = "white",
border_width = 1,
border_color = "gray",
title_color = "white",
element_border_color = "white",
element_border_width = 1
)) |>
add_control("<div style='padding: 5px; background-color: #2E8B57; color: white;'>
<h2>Antarctic Ice Shelves</h2>
Derived from 2003-2004 Mosaic of Antarctica<br />
WGS 84 / Antarctic Polar Stereographic EPSG:3031 limit<br />
Day 22: Natural Earth<br />
data: <a href='https://www.naturalearthdata.com/downloads/10m-
physical-vectors/10m-antarctic-ice-shelves'
style='text-decoration:none;color:lightblue'>10m-antarctic-ice-shelves</a><br />
πš–πšŠπšŒπš”πšŠβ€€πšœπš£πšŽπšŒπš‘πš—πš˜<br />22 November 2025
</div>",
position = "top-right")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment