Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active July 4, 2025 12:32
Show Gist options
  • Save mdsumner/0f752ff89f9e7c5a3f51885773eece56 to your computer and use it in GitHub Desktop.
Save mdsumner/0f752ff89f9e7c5a3f51885773eece56 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mdsumner
Copy link
Author

mdsumner commented Jul 4, 2025

Similar approach in R, as I creep towards parity in these lang, doing something wrong in this or above?

library(terra)
library(glue)
r0 <- rast("AQUA_MODIS.20250704T003501.L2.OC.NRT.nc", c("/navigation_data/longitude", "/navigation_data/latitude"))
crs <- as.character(glue("+proj=laea +lon_0={trunc(mean(r0[[1]][]))} +lat_0={trunc(mean(r0[[2]][]))} +datum=WGS84 +type=crs"))


a <- project(values(r0), to = crs, from = "EPSG:4326")
rc <- c(r0, setNames(setValues(r0, a), c("x", "y")))
plot(rc[["y"]], add = FALSE); contour(rc[["longitude"]], add = T); contour(rc[["latitude"]], add = T, col = "hotpink");

image

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