Last active
November 18, 2025 13:27
-
-
Save h-a-graham/ea4bdc560413ea68b40f60b981e79ea8 to your computer and use it in GitHub Desktop.
Read the Source Coop Alpha Earth Index in R.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Author
h-a-graham
commented
Nov 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment