Skip to content

Commit

Permalink
Add HYDE 3.3. database
Browse files Browse the repository at this point in the history
  • Loading branch information
dramanica committed Oct 20, 2023
1 parent f1d127c commit 951a942
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 321 deletions.
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# pastclim 2.0.0
* Add Barreto et al 2023 (based on PALEO-PGEM, covering the last 5 M years)
* Add all the WorldClim data (present, and future projections with multiple models
and emission scenarios).
and emission scenarios).
* Add the HYDE 3.3 database providing information on agriculture and population sizes
for the last 10k years.
* Change the units of Krapp et al 2021 to match those of other datasets. Also, fix
data duplication of some variables which has now also been fixed on the OSF repository
for that dataset.
data duplication of some variables which has now also been fixed on the OSF repository
for that dataset.
* Improve `get_ice_mask()`, `get_land_mask()`, and `distance_from_sea()` to work
on series rather than just on slices.
* Speed up `region_*()` functions when subsetting the extent/cropping.
Expand Down
31 changes: 31 additions & 0 deletions R/datasets_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,34 @@ NULL
#' @name Barreto2023
NULL
#> NULL

#' Documentation for HYDE 3.3 dataset
#'
#' This database presents an update and expansion of the History Database of
#' the Global Environment (HYDE, v 3.3) and replaces former HYDE 3.2
#' version from 2017. HYDE is and internally consistent combination of
#' updated historical population estimates and land use. Categories
#' include cropland, with a new distinction into irrigated and rain fed
#' crops (other than rice) and irrigated and rain fed rice. Also grazing
#' lands are provided, divided into more intensively used pasture,
#' converted rangeland and non-converted natural (less intensively used)
#' rangeland. Population is represented by maps of total, urban, rural
#' population and population density as well as built-up area.
#'
#' The period covered is 10 000 BCE to 2023 CE. Spatial resolution is
#' 5 arc minutes (approx. 85 km2 at the equator). The full HYDE 3.3 release
#' contains: a Baseline estimate scenario, a Lower estimate scenario and an
#' Upper estimate scenario. Currently only the baseline scenario is available
#' in `pastclim`
#'
#' If you use this dataset, make sure to cite the original publication
#' for the HYDE 3.2 (there is no current publication for 3.3):
#'
#' Klein Goldewijk, K., Beusen, A., Doelman, J., and Stehfest, E.:
#' Anthropogenic land-use estimates for the Holocene; HYDE 3.2,
#' Earth Syst. Sci. Data, 9, 927-953, 2017. \doi{doi.org/10.5194/essd-9-1-2017}
#'
#' @name HYDE_3.3_baseline
NULL
#> NULL

9 changes: 1 addition & 8 deletions R/download_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ download_dataset <- function(dataset, bio_variables = NULL, annual = TRUE,
# check that the variable is available for this dataset
available_variables <-
getOption("pastclim.dataset_list")$variable[getOption("pastclim.dataset_list")$dataset == dataset]
# if variable is null, donwload all possible variables
# if variable is null, download all possible variables
if (is.null(bio_variables)) {
bio_variables <- getOption("pastclim.dataset_list")[getOption("pastclim.dataset_list")$dataset == dataset, ]
if (!monthly) {
Expand All @@ -55,13 +55,6 @@ download_dataset <- function(dataset, bio_variables = NULL, annual = TRUE,
)
}

# if (dataset %in% c("Krapp2021", "Beyer2020", "Example")){
# # add biome to list of variables (we need it to generate the landmask)
# if (!"biome" %in% bio_variables) {
# bio_variables <- c(bio_variables, "biome")
# }
# }

# add biome to list of variables (we need it to generate the landmask)
if (all((!"biome" %in% bio_variables), ("biome" %in% available_variables))) {
bio_variables <- c(bio_variables, "biome")
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
24 changes: 9 additions & 15 deletions R/time_bp.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ setGeneric("time_bp", function(x) {
setMethod(
"time_bp", signature(x = "SpatRaster"),
function(x) {
if (timeInfo(x)$step != "years") {
if (timeInfo(x)$step == "years") {
time_bp <- terra::time(x) - 1950
} else if (any(inherits(terra::time(x), "POSIXct"), inherits(terra::time(x), "Date"))) {
time_bp <- date2ybp(terra::time(x))
} else {
# as of 1.7.18, the bug in terra setting years to negative has ben fixed
stop(
"The time units of SpatRaster are not 'years'.\n",
"The time units of SpatRaster are not 'years' or a 'days'.\n",
"It might be a problem with the time units not being properly set in the original nc file.\n",
"Set time units correctly with time_bp(x)<-c(-10000,-400).\n",
"NOTE do NOT use terra:time, as that terra measures years from 0AD, not BP"
)
}
time_yr <- terra::time(x)
return(time_yr - 1950)

return(time_bp)
}
)

Expand All @@ -46,17 +50,7 @@ setMethod(
if (!is_region_series(x)) {
stop("this is not a valid region series; it should be a SpatRasterDataset where each dataset (i.e. variable) has the same time steps")
}
if (timeInfo(x[[1]])$step != "years") {
# as of 1.7.18, the bug in terra setting years to negative has been fixed
stop(
"The time units of SpatRaster are not 'years'.\n",
"It might be a problem with the time units not being properly set in the original nc file.\n",
"Set time units correctly with time_bp(x)<-c(-10000,-400).\n",
"NOTE do NOT use terra:time, as that terra measures years from 0AD, not BP"
)
}
time_yr <- terra::time(x[[1]])
return(time_yr - 1950)
time_bp(x[[1]])
}
)

Expand Down
4 changes: 2 additions & 2 deletions R/ybp2date.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ybp2date <- function(x) {
#' @rdname ybp2date
#' @export
date2ybp <- function(x) {
if (!inherits(x, "POSIXct")) {
stop("x should be a POSIXct object")
if (!any(inherits(x, "POSIXct"), inherits(x, "Date"))) {
stop("x should be a POSIXct or Date object")
}
lubridate::year(x) - 1950
}
16 changes: 16 additions & 0 deletions data-raw/data_files/dataset_list_included.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6528,3 +6528,19 @@ temperature_max_09,temperature_max_09,WorldClim_2.1_UKESM1-0-LL_ssp585_5m,TRUE,W
temperature_max_10,temperature_max_10,WorldClim_2.1_UKESM1-0-LL_ssp585_5m,TRUE,WorldClim_2.1_UKESM1-0-LL_ssp585_5m_tmax_v1.4.0.nc,,download_worldclim_future,,,1.4.0,maximum temperature Oct,max T Oct,october,degrees Celsius,*degree*C*,
temperature_max_11,temperature_max_11,WorldClim_2.1_UKESM1-0-LL_ssp585_5m,TRUE,WorldClim_2.1_UKESM1-0-LL_ssp585_5m_tmax_v1.4.0.nc,,download_worldclim_future,,,1.4.0,maximum temperature Nov,max T Nov,november,degrees Celsius,*degree*C*,
temperature_max_12,temperature_max_12,WorldClim_2.1_UKESM1-0-LL_ssp585_5m,TRUE,WorldClim_2.1_UKESM1-0-LL_ssp585_5m_tmax_v1.4.0.nc,,download_worldclim_future,,,1.4.0,maximum temperature Dec,max T Dec,december,degrees Celsius,*degree*C*,
cropland,cropland,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_cropland.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/cropland.nc,,,,1.4.0,total cropland area,cropland,annual,km^2 per gridcell,*km^2*,
grazing_land,grazing_land,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_grazing_land.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/grazing_land.nc,,,,1.4.0,total grazing land,grazing land,annual,km^2 per gridcell,*km^2*,
irrigated_rice,irrigated_rice,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_irrigated_rice.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/irrigated_rice.nc,,,,1.4.0,irrigated rice,irrigated rice,annual,km^2 per gridcell,*km^2*,
irrigated_not_rice,irrigated_not_rice,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_irrigated_not_rice.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/irrigated_not_rice.nc,,,,1.4.0,irrigated not rice,irrigated not rice,annual,km^2 per gridcell,*km^2*,
pasture,pasture,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_pasture.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/pasture.nc,,,,1.4.0,total pasture area,pasture,annual,km^2 per gridcell,*km^2*,
population_density,population_density,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_population_density.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/population_density.nc,,,,1.4.0,total population_density area,population_density,annual,km^2 per gridcell,*km^2*,
population,population,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_population.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/population.nc,,,,1.4.0,total population area,population,annual,km^2 per gridcell,*km^2*,
rainfed_not_rice,rainfed_not_rice,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_rainfed_not_rice.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/rainfed_not_rice.nc,,,,1.4.0,total rainfed_not_rice area,rainfed_not_rice,annual,km^2 per gridcell,*km^2*,
rainfed_rice,rainfed_rice,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_rainfed_rice.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/rainfed_rice.nc,,,,1.4.0,total rainfed_rice area,rainfed_rice,annual,km^2 per gridcell,*km^2*,
rangeland,rangeland,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_rangeland.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/rangeland.nc,,,,1.4.0,total rangeland area,rangeland,annual,km^2 per gridcell,*km^2*,
rural_population,rural_population,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_rural_population.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/rural_population.nc,,,,1.4.0,total rural_population area,rural_population,annual,km^2 per gridcell,*km^2*,
total_irrigated,total_irrigated,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_total_irrigated.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/total_irrigated.nc,,,,1.4.0,total total_irrigated area,total_irrigated,annual,km^2 per gridcell,*km^2*,
total_rainfed,total_rainfed,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_total_rainfed.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/total_rainfed.nc,,,,1.4.0,total total_rainfed area,total_rainfed,annual,km^2 per gridcell,*km^2*,
total_rice,total_rice,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_total_rice.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/total_rice.nc,,,,1.4.0,total total_rice area,total_rice,annual,km^2 per gridcell,*km^2*,
urban_area,urban_area,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_urban_area.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/urban_area.nc,,,,1.4.0,total urban_area area,urban_area,annual,km^2 per gridcell,*km^2*,
urban_population,urban_population,HYDE_3.3_baseline,FALSE,HYDE_3.3_baseline_urban_population.nc,https://geo.public.data.uu.nl/vault-hyde-data/HYDE%203.3%5B1696419673%5D/original/Baseline_scenario/NetCDF/urban_population.nc,,,,1.4.0,total urban_population area,urban_population,annual,km^2 per gridcell,*km^2*,
100 changes: 0 additions & 100 deletions data-raw/format_climate_datasets/test_bio_vars.R

This file was deleted.

92 changes: 0 additions & 92 deletions data-raw/format_climate_datasets/test_bio_vars_beyer.R

This file was deleted.

Loading

0 comments on commit 951a942

Please sign in to comment.