BigDataWUR / AgML-CY-Bench

CY-Bench (Crop Yield Benchmark) is a comprehensive dataset and benchmark to forecast crop yields at subnational level. CY-Bench standardizes selection, processing and spatio-temporal harmonization of public subnational yield statistics with relevant predictors. Contributors include agronomers, climate scientists and machine learning researchers.
https://cybench.agml.org/
Other
16 stars 8 forks source link

validate predictor data #290

Open krsnapaudel opened 3 months ago

krsnapaudel commented 3 months ago

Check whether aggregated predictor data looks correct when compared to original rasters. Note aggregation uses crop masks. So comparing visually is probably tricky.

krsnapaudel commented 3 months ago

Here is the example code I wrote to compare soil data.

library(terra)
setwd("AgML/Data")
awc <- rast("WISE Soil/awc.tif")
maize_mask <- rast("crop_masks/crop_mask_maize_WC.tif")

eu_shapes <- vect("Shapefiles/shapefiles_EU/NUTS_RG_01M_2016_4326_LEVL_2.shp")
nl_shapes <- eu_shapes[eu_shapes$CNTR_CODE == "NL"]

awc <- crop(awc, nl_shapes)
maize_mask <- crop(maize_mask, nl_shapes)
maize_mask <- resample(maize_mask, awc, method="bilinear")
awc[maize_mask < 0 | maize_mask > 100] <- NA
awc <- mask(awc, nl_shapes)

soil_data <- read.csv("WISE Soil/soil_maize_NL.csv")
nl_shapes$awc <- soil_data$awc[soil_data$adm_id == nl_shapes$NUTS_ID]

# plot
min_awc <- min(minmax(awc)[1], min(nl_shapes$awc))
max_awc <- max(minmax(awc)[2], max(nl_shapes$awc))
par(mfrow = c(1, 2)) # reset plotting window
plot(nl_shapes, "awc", col=hcl.colors(100, palette="RdYlBu"), type="continuous", range=c(min_awc, max_awc))
plot(awc, col=hcl.colors(100, palette="RdYlBu"), type="continuous", range=c(min_awc, max_awc))
plot(nl_shapes, add=TRUE)
krsnapaudel commented 2 months ago

Results for CY-Bench data look good with AgML workshop validation. See #301. This means the data is mostly likely fine.