View arrow-duckdb-uri-benchmarks.R
This file contains 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
library(arrow) | |
s3 <- s3_bucket("neon4cast-scores/parquet/aquatics", endpoint_override = "data.ecoforecast.org", anonymous=TRUE) | |
bench::bench_time( # very slow | |
ds <- open_dataset(s3) | |
) | |
bench::bench_time( # very slow, but available via S3 Inventory |
View io-biodiversity.R
This file contains 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
library(rstac) | |
library(gdalcubes) | |
# let's pick some spatial extent, say, a bbox around "India" | |
loc <- spData::world |> dplyr::filter(name_long == "India") | |
box <- sf::st_bbox(loc) | |
matches <- | |
stac("https://planetarycomputer.microsoft.com/api/stac/v1") |> | |
stac_search(collections = "io-biodiversity", |
View LPI-precalculated.R
This file contains 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
library(tidyverse) | |
direct <- read_csv("https://www.livingplanetindex.org/session/2ccf2bec98c16e6ee8f9ed6bbd8a514d/download/downloadData?w=") | |
direct |> | |
ggplot(aes(Year, LPI_final)) + geom_line() + geom_ribbon(aes(ymin=CI_low, ymax=CI_high), fill="blue", alpha=0.1) | |
direct |> rename(year = Year) |> mutate(sample = LPI_final + ((CI_high - CI_low)/2) * (runif(n(), -10,10))/10 ) |> | |
ggplot(aes(x = year, y = 1, fill = sample)) + | |
geom_tile(show.legend = FALSE) + | |
#scale_fill_steps2(low = "#c7cca5", mid="#ddff03", high="#53de02", midpoint = median(lpi_df$LPI_final)) + | |
scale_fill_stepsn(colors = c("#c7cca5", "#ddff03", "#53de02"), values = rescale(c(min(lpi_df$sample), 0, max(lpi_df$sample))), |
View efi-duckdb-vs-arrow.R
This file contains 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
library(duckdb) | |
library(DBI) | |
library(glue) | |
library(dplyr) | |
conn <- DBI::dbConnect(duckdb(), ":memory:", | |
config=list("memory_limit"="12GB", | |
"temp_directory" = "/tmp")) | |
DBI::dbExecute(conn, "INSTALL 'httpfs';") | |
DBI::dbExecute(conn, "LOAD 'httpfs';") |
View tidync-co2.R
This file contains 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
#url <- "https://dap.tern.org.au/thredds/ncss/ecosystem_process/ozflux/AdelaideRiver/2022_v2/L5/default/AdelaideRiver_L5_20071017_20090524.nc" | |
library(tidync) | |
library(lubridate) | |
library(dplyr) | |
url <- "https://dap.tern.org.au/thredds/dodsC/ecosystem_process/ozflux/AdelaideRiver/2022_v2/L5/default/AdelaideRiver_L5_20071017_20090524.nc" | |
# peek at metadata for time units | |
nc_atts(url) |> filter(variable=="time") |> mutate(value = unlist(value)) |
View sf-ndvi-sentinel.R
This file contains 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
library(rstac) | |
library(gdalcubes) | |
library(stars) | |
library(tmap) | |
## STAC Search over 400 million assets. | |
box <- c(xmin=-122.51006, ymin=37.70801, xmax=-122.36268, ymax=37.80668) | |
start_date <- "2022-06-01" | |
end_date <- "2022-08-01" |
View brazil-modis-ndvi-ex.R
This file contains 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
# remotes::install_github("OldLipe/rstac@b-0.9.1") | |
# remotes::install_github("appelmar/gdalcubes_R") | |
# remotes::install_github("r-spatial/stars") | |
library(tidyverse) | |
library(rstac) | |
library(gdalcubes) | |
library(tmap) | |
library(stars) | |
data(World) #polygons |
View gefs-cubes.R
This file contains 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
library(gdalcubes) | |
library(gefs4cast) # remotes::install_github("neon4cast/gefs4cast") | |
library(stringr) | |
library(lubridate) | |
## 3-hr period up to 10 days, (then every 6 hrs up to 35 day horizon) | |
gefs_cog("~/gefs_cog", ens_avg=TRUE, | |
max_horizon=240, date = Sys.Date() - 1) |> system.time() | |
# 000 file has different bands and so cannot be stacked into the collection |
View gdalcubes.R
This file contains 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
#remotes::install_github("OldLipe/rstac@dev") | |
#remotes::install_github("appelmar/gdalcubes_R") | |
source("new_sign_planetary_computer.R") | |
sites <- readr::read_csv(paste0("https://github.com/eco4cast/neon4cast-noaa-download/", | |
"raw/master/noaa_download_site_list.csv")) | |
z <- sites |> dplyr::filter(site_id == "HARV") | |
y <- z$latitude |
View modis-LAI.R
This file contains 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
library(tidyverse) | |
library(rstac) | |
library(httr) | |
library(stars) | |
library(spData) | |
box <- st_bbox(us_states) | |
# hack around rstac bug in signing | |
mysign <- function(href) { |
NewerOlder