Spilhaus

[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This image shows abundant phytoplankton, known as a bloom, as swirls of green in the Gulf of Alaska on June 9, 2016

Monitoring the Single-Celled Powerhouses of the Sea – CC-BY-NC by NASA’s Marshall Space Flight Center

Day 26 of 30DayMapChallenge: « Map projections » (previously).

After seeing this post by Cédric Vidonne I had to try to use the Spilhaus projection too.

Config

library(dplyr)
library(ggplot2)
library(scales)
library(glue)
library(terra)

source("spilhaus.R") # from https://github.com/rtlemos/spilhaus/ see below

Data

Mass concentration of chlorophyll a in sea water. Get the current data from Copernicus: Global Ocean Biogeochemistry Analysis and Forecast (European Union-Copernicus Marine Service 2019). You’ll need to register first.

An API is available, but for this one shot a manual download is easier:

Copernicus Marine Data Store

Add layer

Download
chlorophyll <- rast("cmems_mod_glo_bgc-pft_anfc_0.25deg_P1D-m_1732694885194.nc")

Reproject

Based on the functions made by Ricardo T. Lemos.

spilhaus_df <- make_spilhaus_xy_gridpoints(spilhaus_res = 1000)
lonlat <- from_spilhaus_xy_to_lonlat(spilhaus_df$x, spilhaus_df$y)

spilhaus_df$z <- pull(extract(chlorophyll, lonlat), 1)
spilhaus_df$l <- is.na(spilhaus_df$z)

pretty_spilhaus_df <- pretify_spilhaus_df(spilhaus_df)

Map

pretty_spilhaus_df |> 
  ggplot(aes(x, y, fill = z)) +
  geom_raster() +
  scale_fill_viridis_c(option = "viridis",
                       limits = c(0, .8),
                       na.value = viridis_pal()(2)[2],
                       name = bquote(atop("2024-11-28", "Chlorophyll a ("*mg %.% m^-3*")"))) +
  coord_equal() +
  labs(caption = glue("https://r.iresmi.net/ - {Sys.Date()}
                      Generated using E.U. Copernicus Marine Service Information 10.48670/moi-00015")) +
  theme_void() +
  theme(plot.background = element_rect(fill = "black", 
                                        color = "black"),
        plot.caption = element_text(size = 6, 
                                    color = "darkgrey"),
        legend.position = c(0.85, 0.85), 
        legend.title = element_text(color = "white"),
        legend.text = element_text(color = "white"))
Map of Mass concentration of chlorophyll a in sea water
Figure 1: Mass concentration of chlorophyll a in sea water – 2024-11-28

References

European Union-Copernicus Marine Service. 2019. “Global Ocean Biogeochemistry Analysis and Forecast.” Mercator Ocean International. https://doi.org/10.48670/MOI-00015.
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)