Skip to content

Instantly share code, notes, and snippets.

View mdsumner's full-sized avatar

Michael Sumner mdsumner

  • Integrated Digital East Antarctica, Australian Antarctic Division
  • Hobart, Australia
View GitHub Profile

https://stat.ethz.ch/pipermail/r-sig-geo/2025-May/029541.html

Below we calculate individual distances along polygon edges, and sum up. This works here only because this is a single-ring polygon.

The numbers in play are

129.248935: the planar distance in the crs

129.285384: the "true" distance, to some insanely accurate level

raw history, relevant calls are with anglr:: and rgl functions (ignore the ggplot that's interleaved I was checking against plots)

library(anglr)
as.contour(large_topo_spat)
as.contour(large_topo_spat, levels = c(-1500, -1100, -700, -300, 0))
plot3d(as.contour(large_topo_spat, levels = c(-1500, -1100, -700, -300, 0)))
plot3d(sf::st_as_sf(as.contour(large_topo_spat, levels = c(-1500, -1100, -700, -300, 0))))

Here's some examples of using the new NASA experimental json Zarr

with xarray

import xarray 
## no
#import earthaccess
#earthaccess.login()  ## use env vars ??
#fs = earthaccess.get_s3_filesystem(daac="podaac")
longstrings <- c("analysis.\\\",\\\"title\\\":\\\"RSS CCMP V3.1 6-hourly surface winds (Level 4)\\\",\\\"coordinates\\\":\\\"latitude longitude t", 
                 "dsaoijdoijdd09d9de9e9e9e00\"RSS CCMPbalsljdojasdoiewwiow8us98hasdhasd")

findregions <- function(x, pattern, window = 10) {
  index <- gregexpr(pattern, x)
  outlist <- vector("list", length(index))
  for (i in seq_along(index)) {
    outlist[[i]] <- character(length(index[[i]]))
 for (j in seq_along(index[[i]])) {
## Read Nuyina underway (1-minute interval data collection from the ocean)
get_underway <- function(x) {
  ## read the bulk
  d <- arrow::read_parquet("https://github.com/mdsumner/nuyina.underway/raw/main/data-raw/nuyina_underway.parquet")
  ## read the rest
  d1 <- tibble::as_tibble(vapour::vapour_read_fields("WFS:https://data.aad.gov.au/geoserver/ows?service=wfs&version=2.0.0&request=GetCapabilities",
                                                     sql = sprintf("SELECT * FROM \"underway:nuyina_underway\" WHERE datetime > '%s'", 
                                                                   format(max(d$datetime, "%Y-%m-%dT%H:%M:%SZ")))))
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"source"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20000101_20001231_epsg3031.tif"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20010101_20011231_epsg3031.tif"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20020101_20021231_epsg3031.tif"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20030101_20031231_epsg3031.tif"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20040101_20041231_epsg3031.tif"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20050101_20051231_epsg3031.tif"
"https://projects.pawsey.org.au/ant-11-era5-evaluation/ps_ANT-11_ERA5_evaluation_r1i1p1f1_BAS_MetUM_v1-r1_day_20060101_20061231_epsg3031.tif"
"https://projects.paw
library(reticulate)
p <- c("polars", "h5netcdf", "fsspec", "aiohttp", "requests", "xarray", "dask")
py_require(p)
polars <- import("polars")
xarray <- import("xarray")

pp <-  arrow::read_parquet("https://projects.pawsey.org.au/idea-objects/idea-curated-objects.parquet")
## in R before
# p <- c("polars", "h5netcdf", "fsspec", "aiohttp", "requests", "xarray")
# reticulate::py_require(p)

import polars
pp = polars.read_parquet("https://projects.pawsey.org.au/idea-objects/idea-curated-objects.parquet")
d = pp.filter(polars.col("Dataset") == "oisst-avhrr-v02r01")
d = d.with_columns(source = polars.format("https://projects.pawsey.org.au/{}/{}", polars.col("Bucket"), polars.col("Key")))
dsn <- "https://raw.githubusercontent.com/OSGeo/gdal/refs/heads/master/frmts/wms/frmt_wms_bluemarble_s3_tms.xml"
library(terra)
r <- rast(dsn)



## first I did
m <- do.call(cbind, maps::map(plot = F)[1:2])
plot(project(m, to = "+proj=isea", from = "EPSG:4326"), pch = ".", asp = 1)