Skip to content

Instantly share code, notes, and snippets.

@h-a-graham
Last active November 18, 2025 13:27
Show Gist options
  • Select an option

  • Save h-a-graham/ea4bdc560413ea68b40f60b981e79ea8 to your computer and use it in GitHub Desktop.

Select an option

Save h-a-graham/ea4bdc560413ea68b40f60b981e79ea8 to your computer and use it in GitHub Desktop.
Read the Source Coop Alpha Earth Index in R.
options(nanoarrow.warn_unregistered_extension = FALSE)
bbox <- gdalraster::bbox_to_wkt(
c(
xmin = 86.05,
ymin = 27.56,
xmax = 87.85,
ymax = 28.62
)
)
idx_pq <- "/vsicurl/https://data.source.coop/tge-labs/aef/v1/annual/aef_index.parquet"
aef_idx <- new(
gdalraster::GDALVector,
idx_pq
)
stream <- aef_idx$getArrowStream()
geodf <- as.data.frame(stream)
geodf_spflt <- geodf[
sapply(geodf[["geom"]], \(x) gdalraster::g_intersects(x, bbox)),
]
geodf_spflt$gdal_path <- gsub(
"\\.(tiff?|TIFF?)$",
".vrt",
gsub("^s3://", "/vsis3/", geodf_spflt$path)
)
Sys.setenv(
AWS_NO_SIGN_REQUEST = "YES"
)
vrtility::plot_raster_src(geodf_spflt$gdal_path[3], bands = c(1, 2, 3))
aef_idx$close() # Close the dataset
options(nanoarrow.warn_unregistered_extension = FALSE)
idx_pq <- "/vsicurl/https://data.source.coop/tge-labs/aef/v1/annual/aef_index.parquet"
aef_idx <- new(
gdalraster::GDALVector,
idx_pq
)
stream <- aef_idx$getArrowStream()
geodf <- as.data.frame(stream)
# and if you want it as an sf object.
geodf_sf <- sf::st_as_sf(geodf, sf_column_name = "geom", crs = 4326)
@h-a-graham
Copy link
Author

image

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