diff --git a/_Rmd/pacific-centered-world-maps.Rmd b/_Rmd/pacific-centered-world-maps.Rmd index 51b0a933e..47272a6b2 100644 --- a/_Rmd/pacific-centered-world-maps.Rmd +++ b/_Rmd/pacific-centered-world-maps.Rmd @@ -5,7 +5,7 @@ series: title: "How to center a world map on the Pacific" subtitle: "One ocean, eight projections" excerpt: >- - Move the cut to Greenwich, put the Pacific in the middle, and draw + Move the cut to Greenwich, put the Pacific in the middle and draw the same world in eight different projections with sf and ggplot2. description: >- Use sf, giscoR and ggplot2 to cut world polygons at a new meridian and @@ -110,7 +110,10 @@ map_theme <- theme_void(base_family = map_title) + project_world <- function(world, projection, lon_0 = 180) { crs <- paste0(projection, " +lon_0=", lon_0) - parts <- st_sf(source_row = seq_len(nrow(world)), geometry = st_geometry(world)) |> + parts <- st_sf( + source_row = seq_len(nrow(world)), + geometry = st_geometry(world) + ) |> st_break_antimeridian(lon_0 = lon_0) projected <- parts |> @@ -264,9 +267,10 @@ change the center and leave the polygons as they are. #| fig-width: 10.5 #| fig-height: 2.25 #| fig-alt: >- -#| Three Robinson maps. The Greenwich-centered map has the Pacific at the -#| edges. The Pacific-centered map has horizontal stripes before cutting -#| and a clear ocean after cutting. +#| Three Robinson maps side by side. The left map is centered on Greenwich +#| and splits the Pacific between its edges. The middle map is centered on +#| the Pacific before cutting. Horizontal stripes of land fill its northern +#| half. The right map is cut first and shows one clear ocean in the middle. greenwich <- project_world(world, "+proj=robin", lon_0 = 0) uncut <- st_transform(world, "+proj=robin +lon_0=180") @@ -308,7 +312,7 @@ other centers, it falls inside the map, where the original split in the I regroup the pieces by country and use small buffers to close gaps along that interior seam in geographic coordinates, while it is still a straight line. -
+
## Cut first, project second
@@ -96,7 +96,7 @@ other centers, it falls inside the map, where the original split in the
I regroup the pieces by country and use small buffers to close gaps along that
interior seam in geographic coordinates, while it is still a straight line.
-
+
+
© EuroGeographics for the administrative boundaries
{: .caption }
@@ -302,12 +305,13 @@ You can move the center again. Try
`project_world(world, "+proj=robin", lon_0 = -90)` to center the map at 90° W
and put the cut at 90° E.
-**Cut first, project second**. That’s the whole trick.
+**Cut first, project second**. That's the whole trick.
You can change `lon_0` freely. If you run into polygons that break or gaps
that don't close cleanly, I'd like to see them.
+