├── inst ├── tmp │ └── gitkeep ├── extdata │ ├── .gitignore │ ├── burundi.gpkg │ ├── gfw_sample.gpkg │ ├── burundi_worldpop.tif │ ├── sierra_de_neiba_478140.gpkg │ ├── sierra_de_neiba_478140_2.gpkg │ └── shell_beach_protected_area_41057_B.gpkg └── res │ ├── teow │ ├── wwf_terr_ecos.zip │ └── wwf_terr_ecos.gpkg │ ├── chirps │ ├── .gitignore │ ├── chirps-v2.0.2010.01.tif.gz │ ├── chirps-v2.0.2010.02.tif.gz │ ├── chirps-v2.0.2010.03.tif.gz │ ├── chirps-v2.0.2010.04.tif.gz │ ├── chirps-v2.0.2010.05.tif.gz │ ├── chirps-v2.0.2010.06.tif.gz │ ├── chirps-v2.0.2010.07.tif.gz │ ├── chirps-v2.0.2010.08.tif.gz │ ├── chirps-v2.0.2010.09.tif.gz │ ├── chirps-v2.0.2010.10.tif.gz │ ├── chirps-v2.0.2010.11.tif.gz │ ├── chirps-v2.0.2010.12.tif.gz │ ├── chirps-v2.0.2010.01.tif │ ├── chirps-v2.0.2010.02.tif │ ├── chirps-v2.0.2010.03.tif │ ├── chirps-v2.0.2010.04.tif │ ├── chirps-v2.0.2010.05.tif │ ├── chirps-v2.0.2010.06.tif │ ├── chirps-v2.0.2010.07.tif │ ├── chirps-v2.0.2010.08.tif │ ├── chirps-v2.0.2010.09.tif │ ├── chirps-v2.0.2010.10.tif │ ├── chirps-v2.0.2010.11.tif │ └── chirps-v2.0.2010.12.tif │ ├── esalandcover │ ├── .gitignore │ ├── W080N20_LC100_v3.0.1_2015.tif │ ├── W080N20_LC100_v3.0.1_2016.tif │ ├── W080N20_LC100_v3.0.1_2017.tif │ ├── W080N20_LC100_v3.0.1_2018.tif │ └── W080N20_LC100_v3.0.1_2019.tif │ ├── nasa_grace │ ├── .gitignore │ ├── gws_perc_025deg_GL_20220103.tif │ ├── gws_perc_025deg_GL_20220110.tif │ ├── gws_perc_025deg_GL_20220117.tif │ ├── gws_perc_025deg_GL_20220124.tif │ ├── gws_perc_025deg_GL_20220131.tif │ ├── gws_perc_025deg_GL_20220207.tif │ ├── gws_perc_025deg_GL_20220214.tif │ ├── gws_perc_025deg_GL_20220221.tif │ ├── gws_perc_025deg_GL_20220228.tif │ ├── gws_perc_025deg_GL_20220307.tif │ ├── gws_perc_025deg_GL_20220314.tif │ ├── gws_perc_025deg_GL_20220321.tif │ ├── gws_perc_025deg_GL_20220328.tif │ ├── gws_perc_025deg_GL_20220404.tif │ ├── gws_perc_025deg_GL_20220411.tif │ ├── gws_perc_025deg_GL_20220418.tif │ ├── gws_perc_025deg_GL_20220425.tif │ ├── gws_perc_025deg_GL_20220502.tif │ ├── gws_perc_025deg_GL_20220509.tif │ └── gws_perc_025deg_GL_20220516.tif │ ├── nasa_srtm │ ├── .gitignore │ └── NASADEM_HGT_n18w072.tif │ ├── nelson_et_al │ ├── .gitignore │ └── traveltime-100k_200k.tif │ ├── worldclim_max_temperature │ ├── .gitignore │ ├── wc2.1_2.5m_tmax_2018-01.tif │ ├── wc2.1_2.5m_tmax_2018-02.tif │ ├── wc2.1_2.5m_tmax_2018-03.tif │ ├── wc2.1_2.5m_tmax_2018-04.tif │ ├── wc2.1_2.5m_tmax_2018-05.tif │ ├── wc2.1_2.5m_tmax_2018-06.tif │ ├── wc2.1_2.5m_tmax_2018-07.tif │ ├── wc2.1_2.5m_tmax_2018-08.tif │ ├── wc2.1_2.5m_tmax_2018-09.tif │ ├── wc2.1_2.5m_tmax_2018-10.tif │ ├── wc2.1_2.5m_tmax_2018-11.tif │ └── wc2.1_2.5m_tmax_2018-12.tif │ ├── worldclim_min_temperature │ ├── .gitignore │ ├── wc2.1_2.5m_tmin_2018-01.tif │ ├── wc2.1_2.5m_tmin_2018-02.tif │ ├── wc2.1_2.5m_tmin_2018-03.tif │ ├── wc2.1_2.5m_tmin_2018-04.tif │ ├── wc2.1_2.5m_tmin_2018-05.tif │ ├── wc2.1_2.5m_tmin_2018-06.tif │ ├── wc2.1_2.5m_tmin_2018-07.tif │ ├── wc2.1_2.5m_tmin_2018-08.tif │ ├── wc2.1_2.5m_tmin_2018-09.tif │ ├── wc2.1_2.5m_tmin_2018-10.tif │ ├── wc2.1_2.5m_tmin_2018-11.tif │ └── wc2.1_2.5m_tmin_2018-12.tif │ ├── worldclim_precipitation │ ├── .gitignore │ ├── wc2.1_2.5m_prec_2018-01.tif │ ├── wc2.1_2.5m_prec_2018-02.tif │ ├── wc2.1_2.5m_prec_2018-03.tif │ ├── wc2.1_2.5m_prec_2018-04.tif │ ├── wc2.1_2.5m_prec_2018-05.tif │ ├── wc2.1_2.5m_prec_2018-06.tif │ ├── wc2.1_2.5m_prec_2018-07.tif │ ├── wc2.1_2.5m_prec_2018-08.tif │ ├── wc2.1_2.5m_prec_2018-09.tif │ ├── wc2.1_2.5m_prec_2018-10.tif │ ├── wc2.1_2.5m_prec_2018-11.tif │ └── wc2.1_2.5m_prec_2018-12.tif │ ├── gmw │ ├── gmw_v3_1996_vec.gpkg │ └── gmw_v3_2016_vec.gpkg │ ├── ucdp_ged │ └── ged221-csv.gpkg │ ├── humanfootprint │ └── hfp2010.tif │ ├── iucn │ ├── Amphibians_SR_2023.tif │ └── Birds_THR_SR_2023.tif │ ├── acled │ └── acled_events_2000.gpkg │ ├── accessibility_2000 │ └── acc_50k.tif │ ├── key_biodiversity_areas │ └── kbas.gpkg │ ├── chelsa │ ├── CHELSA_pr_01_2010_V.2.1.tif │ ├── CHELSA_pr_02_2010_V.2.1.tif │ ├── CHELSA_pr_03_2010_V.2.1.tif │ ├── CHELSA_pr_04_2010_V.2.1.tif │ ├── CHELSA_pr_05_2010_V.2.1.tif │ ├── CHELSA_pr_06_2010_V.2.1.tif │ ├── CHELSA_pr_07_2010_V.2.1.tif │ ├── CHELSA_pr_08_2010_V.2.1.tif │ ├── CHELSA_pr_09_2010_V.2.1.tif │ ├── CHELSA_pr_10_2010_V.2.1.tif │ ├── CHELSA_pr_11_2010_V.2.1.tif │ └── CHELSA_pr_12_2010_V.2.1.tif │ ├── fritz_et_al │ └── geo_fritz_et_al_100m.tif │ ├── ipbes_biomes │ └── IPBES_UoA_biomes_JK.tif │ ├── man_carbon │ ├── Manageable_C_Soil_2010.tif │ ├── Manageable_C_Soil_2018.tif │ ├── Manageable_C_Total_2010.tif │ ├── Manageable_C_Total_2018.tif │ ├── Manageable_C_Biomass_2010.tif │ └── Manageable_C_Biomass_2018.tif │ ├── vul_carbon │ ├── Vulnerable_C_Soil_2010.tif │ ├── Vulnerable_C_Soil_2018.tif │ ├── Vulnerable_C_Total_2010.tif │ ├── Vulnerable_C_Total_2018.tif │ ├── Vulnerable_C_Biomass_2010.tif │ └── Vulnerable_C_Biomass_2018.tif │ ├── worldpop │ ├── ppp_2007_1km_Aggregated.tif │ ├── ppp_2010_1km_Aggregated.tif │ ├── ppp_2011_1km_Aggregated.tif │ ├── ppp_2012_1km_Aggregated.tif │ ├── ppp_2013_1km_Aggregated.tif │ ├── ppp_2014_1km_Aggregated.tif │ ├── ppp_2015_1km_Aggregated.tif │ ├── ppp_2016_1km_Aggregated.tif │ ├── ppp_2017_1km_Aggregated.tif │ ├── ppp_2018_1km_Aggregated.tif │ ├── ppp_2019_1km_Aggregated.tif │ └── ppp_2020_1km_Aggregated.tif │ ├── irr_carbon │ ├── Irrecoverable_C_Soil_2010.tif │ ├── Irrecoverable_C_Soil_2018.tif │ ├── Irrecoverable_C_Total_2010.tif │ ├── Irrecoverable_C_Total_2018.tif │ ├── Irrecoverable_C_Biomass_2010.tif │ └── Irrecoverable_C_Biomass_2018.tif │ ├── gsw_time_series │ ├── v5_2000-0000280000-0000480000.tif │ └── v5_2001-0000280000-0000480000.tif │ ├── gfw_lossyear │ └── Hansen_GFC-2023-v1.11_lossyear_20N_080W.tif │ ├── global_surface_water_change │ └── change_60W_10Nv1_4_2021.tif │ ├── gfw_treecover │ └── Hansen_GFC-2023-v1.11_treecover2000_20N_080W.tif │ ├── global_surface_water_occurrence │ └── occurrence_60W_10Nv1_4_2021.tif │ ├── global_surface_water_recurrence │ └── recurrence_60W_10Nv1_4_2021.tif │ ├── mcd64a1 │ ├── MCD64A1.A2010001.h11v07.061.2021309000505_Burn_Date.tif │ ├── MCD64A1.A2010032.h11v07.061.2021309000639_Burn_Date.tif │ ├── MCD64A1.A2010060.h11v07.061.2021309000812_Burn_Date.tif │ ├── MCD64A1.A2010091.h11v07.061.2021309001013_Burn_Date.tif │ ├── MCD64A1.A2010121.h11v07.061.2021309001139_Burn_Date.tif │ ├── MCD64A1.A2010152.h11v07.061.2021309001301_Burn_Date.tif │ ├── MCD64A1.A2010182.h11v07.061.2021309001436_Burn_Date.tif │ ├── MCD64A1.A2010213.h11v07.061.2021309001642_Burn_Date.tif │ ├── MCD64A1.A2010244.h11v07.061.2021309001834_Burn_Date.tif │ ├── MCD64A1.A2010274.h11v07.061.2021309002047_Burn_Date.tif │ ├── MCD64A1.A2010305.h11v07.061.2021309002236_Burn_Date.tif │ └── MCD64A1.A2010335.h11v07.061.2021309002413_Burn_Date.tif │ ├── global_surface_water_seasonality │ └── seasonality_60W_10Nv1_4_2021.tif │ ├── global_surface_water_transitions │ └── transitions_60W_10Nv1_4_2021.tif │ ├── gfw_emissions │ └── gfw_forest_carbon_gross_emissions_Mg_CO2e_px_20N_080W.tif │ └── biodiversity_intactness_index │ └── lbii.asc ├── .github ├── .gitignore └── workflows │ ├── test-coverage.yaml │ └── pkgdown.yaml ├── vignettes ├── .gitignore ├── assets │ └── img │ │ └── wide-long-tables.png ├── workflow.Rmd └── installation.Rmd ├── man ├── figures │ └── logo.png ├── check_available_years.Rd ├── check_namespace.Rd ├── nasa_grace.Rd ├── nasa_srtm.Rd ├── accessibility_2000.Rd ├── make_global_grid.Rd ├── worldpop.Rd ├── iucn.Rd ├── gmw.Rd ├── biodiversity_intactness_index_resource.Rd ├── ipbes_biome_stats.Rd ├── biome.Rd ├── worldclim_precipitation.Rd ├── deforestation_drivers.Rd ├── ucdp_ged.Rd ├── ecoregion.Rd ├── worldclim_max_temperature.Rd ├── worldclim_min_temperature.Rd ├── esalandcover.Rd ├── mangroves_area.Rd ├── chirps.Rd ├── spds_exists.Rd ├── global_surface_water_seasonality.Rd ├── landcover.Rd ├── key_biodiversity_areas_indicator.Rd ├── key_biodiversity_areas_resource.Rd ├── gsw_seasonality.Rd ├── teow.Rd ├── fritz_et_al.Rd ├── chelsa.Rd ├── gfw_treecover.Rd ├── biodiversity_intactness_index_indicator.Rd ├── global_surface_water_occurrence.Rd ├── gfw_emissions.Rd ├── elevation.Rd ├── slope.Rd ├── indicators.Rd ├── global_surface_water_recurrence.Rd ├── gfw_lossyear.Rd ├── precipitation_chelsa.Rd └── precipitation_chirps.Rd ├── pkgdown └── favicon │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── apple-touch-icon.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ └── apple-touch-icon-180x180.png ├── extras └── mapme.biodiversity_resources.xlsx ├── tests ├── testthat │ ├── _snaps │ │ ├── calc_traveltime.md │ │ ├── calc_elevation.md │ │ ├── calc_slope.md │ │ ├── calc_soilproperties.md │ │ ├── calc_traveltime_2000.md │ │ ├── calc_tri.md │ │ ├── calc_treecover_area.md │ │ ├── calc_treecoverloss_emissions.md │ │ ├── calc_burned_area.md │ │ ├── calc_population_count.md │ │ ├── calc_temperature_max_wc.md │ │ ├── calc_precipitation_wc.md │ │ ├── calc_temperature_min_wc.md │ │ ├── calc_precipitation_chelsa.md │ │ ├── calc_treecover_area_and_emissions.md │ │ └── calc_drought_indicator.md │ ├── test-get_teow.R │ ├── test-get_chelsa.R │ ├── test-get_nasa_grace.R │ ├── test-get_nelson_et_al.R │ ├── test-get_gmw.R │ ├── test-get_chirps.R │ ├── test-get_gfw_emissions.R │ ├── test-get_acled.R │ ├── test-get_accessibility_2000.R │ ├── test-get_gfw_lossyear.R │ ├── test-get_worldpop.R │ ├── test-get_nasa_srtm.R │ ├── test-get_fritz_et_al.R │ ├── test-get_mcd64A1.R │ ├── test-calc_hfp.R │ ├── test-calc_landcover.R │ ├── test-get_esalandcover.R │ ├── test-get_gfw_treecover.R │ ├── test-get_hfp.R │ ├── test-get_ucdp_ged.R │ ├── test-get_soilgrids.R │ ├── test-calc_gsw_change.R │ ├── test-calc_gsw_occurrence.R │ ├── test-calc_gsw_recurrence.R │ ├── test-calc_mangroves_area.R │ ├── test-calc_biome.R │ ├── test-calc_ecoregion.R │ ├── test-get_iucn.R │ ├── test-calc_gsw_seasonality.R │ ├── test-calc_deforestation_drivers.R │ ├── test-calc_biodiversity_intactness_index.R │ ├── test-get_key_biodiversity_areas.R │ ├── test-get_biodiversity_intactness_index.R │ ├── test-calc_burned_area.R │ ├── test-ipbes.R │ ├── test-calc_gsw_transitions.R │ ├── test-calc_iucn.R │ ├── test-get_carbon.R │ ├── test-calc_elevation.R │ ├── test-utils.R │ ├── test-calc_tri.R │ ├── test-calc_population_count.R │ ├── test-calc_soilproperties.R │ ├── test-calc_precipitation_chelsa.R │ ├── test-calc_traveltime.R │ ├── test-get_worldclim.R │ ├── test-calc_precipitation_wc.R │ ├── test-calc_drought_indicator.R │ ├── test-calc_key_biodiversity_areas.R │ ├── test-calc_traveltime_2000.R │ ├── test-calc_temperature_max_wc.R │ ├── test-calc_temperature_min_wc.R │ ├── test-calc_gsw_time_series.R │ ├── test-calc_precipitation_chirps.R │ ├── test-get_gsw.R │ ├── test-calc_fatalities_ucpd.R │ └── test-get_gsw_time_series.R └── testthat.R ├── mapme.biodiversity.Rproj ├── data-raw ├── key_biodiversity_areas.R ├── ipbes.R ├── hfp.R ├── iucn.R ├── mcd64a1.R ├── fritz_et_al.R ├── biodiversity_intactness_index.R ├── chelsa.R ├── nasa_grace.R ├── ucdp-ged.R ├── nasa_srtm.R ├── chirps.R ├── gsw_time_series.R ├── gsw.R ├── accessibility_2000.R ├── carbon.R ├── gfw_treecover.R └── worldclim.R ├── R └── mapme.biodiversity-pkg.R ├── .Rbuildignore ├── .pre-commit-config.yaml └── .gitignore /inst/tmp/gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/extdata/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /inst/res/teow/wwf_terr_ecos.zip: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.01.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.02.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.03.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.04.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.05.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.06.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.07.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.08.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.09.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.10.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.11.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.12.tif.gz: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/res/esalandcover/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /inst/res/nasa_grace/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /inst/res/nasa_srtm/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /inst/res/nelson_et_al/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/.gitignore: -------------------------------------------------------------------------------- 1 | *.gpkg 2 | -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /inst/extdata/burundi.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/extdata/burundi.gpkg -------------------------------------------------------------------------------- /inst/extdata/gfw_sample.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/extdata/gfw_sample.gpkg -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /inst/extdata/burundi_worldpop.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/extdata/burundi_worldpop.tif -------------------------------------------------------------------------------- /inst/res/gmw/gmw_v3_1996_vec.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gmw/gmw_v3_1996_vec.gpkg -------------------------------------------------------------------------------- /inst/res/gmw/gmw_v3_2016_vec.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gmw/gmw_v3_2016_vec.gpkg -------------------------------------------------------------------------------- /inst/res/teow/wwf_terr_ecos.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/teow/wwf_terr_ecos.gpkg -------------------------------------------------------------------------------- /inst/res/ucdp_ged/ged221-csv.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/ucdp_ged/ged221-csv.gpkg -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /inst/res/humanfootprint/hfp2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/humanfootprint/hfp2010.tif -------------------------------------------------------------------------------- /inst/res/iucn/Amphibians_SR_2023.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/iucn/Amphibians_SR_2023.tif -------------------------------------------------------------------------------- /inst/res/iucn/Birds_THR_SR_2023.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/iucn/Birds_THR_SR_2023.tif -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /inst/res/acled/acled_events_2000.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/acled/acled_events_2000.gpkg -------------------------------------------------------------------------------- /extras/mapme.biodiversity_resources.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/extras/mapme.biodiversity_resources.xlsx -------------------------------------------------------------------------------- /inst/extdata/sierra_de_neiba_478140.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/extdata/sierra_de_neiba_478140.gpkg -------------------------------------------------------------------------------- /inst/res/accessibility_2000/acc_50k.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/accessibility_2000/acc_50k.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.01.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.01.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.02.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.02.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.03.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.03.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.04.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.04.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.05.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.05.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.06.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.06.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.07.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.07.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.08.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.08.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.09.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.09.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.10.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.10.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.11.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.11.tif -------------------------------------------------------------------------------- /inst/res/chirps/chirps-v2.0.2010.12.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chirps/chirps-v2.0.2010.12.tif -------------------------------------------------------------------------------- /inst/res/key_biodiversity_areas/kbas.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/key_biodiversity_areas/kbas.gpkg -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_traveltime.md: -------------------------------------------------------------------------------- 1 | # traveltime works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 314.7566 7 | 8 | -------------------------------------------------------------------------------- /vignettes/assets/img/wide-long-tables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/vignettes/assets/img/wide-long-tables.png -------------------------------------------------------------------------------- /inst/extdata/sierra_de_neiba_478140_2.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/extdata/sierra_de_neiba_478140_2.gpkg -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_01_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_01_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_02_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_02_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_03_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_03_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_04_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_04_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_05_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_05_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_06_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_06_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_07_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_07_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_08_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_08_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_09_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_09_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_10_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_10_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_11_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_11_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/chelsa/CHELSA_pr_12_2010_V.2.1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/chelsa/CHELSA_pr_12_2010_V.2.1.tif -------------------------------------------------------------------------------- /inst/res/nasa_srtm/NASADEM_HGT_n18w072.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_srtm/NASADEM_HGT_n18w072.tif -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_elevation.md: -------------------------------------------------------------------------------- 1 | # srtm elevation works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 1704.491 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_slope.md: -------------------------------------------------------------------------------- 1 | # slope calculation works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 17.81532 7 | 8 | -------------------------------------------------------------------------------- /inst/res/fritz_et_al/geo_fritz_et_al_100m.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/fritz_et_al/geo_fritz_et_al_100m.tif -------------------------------------------------------------------------------- /inst/res/ipbes_biomes/IPBES_UoA_biomes_JK.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/ipbes_biomes/IPBES_UoA_biomes_JK.tif -------------------------------------------------------------------------------- /inst/res/man_carbon/Manageable_C_Soil_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/man_carbon/Manageable_C_Soil_2010.tif -------------------------------------------------------------------------------- /inst/res/man_carbon/Manageable_C_Soil_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/man_carbon/Manageable_C_Soil_2018.tif -------------------------------------------------------------------------------- /inst/res/nelson_et_al/traveltime-100k_200k.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nelson_et_al/traveltime-100k_200k.tif -------------------------------------------------------------------------------- /inst/res/vul_carbon/Vulnerable_C_Soil_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/vul_carbon/Vulnerable_C_Soil_2010.tif -------------------------------------------------------------------------------- /inst/res/vul_carbon/Vulnerable_C_Soil_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/vul_carbon/Vulnerable_C_Soil_2018.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2007_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2007_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2010_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2010_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2011_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2011_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2012_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2012_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2013_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2013_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2014_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2014_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2015_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2015_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2016_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2016_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2017_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2017_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2018_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2018_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2019_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2019_1km_Aggregated.tif -------------------------------------------------------------------------------- /inst/res/worldpop/ppp_2020_1km_Aggregated.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldpop/ppp_2020_1km_Aggregated.tif -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_soilproperties.md: -------------------------------------------------------------------------------- 1 | # soilpoperties works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 34.9959 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_traveltime_2000.md: -------------------------------------------------------------------------------- 1 | # traveltime_2000 works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 379.7454 7 | 8 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_tri.md: -------------------------------------------------------------------------------- 1 | # terrain ruggedness index works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 33.27108 7 | 8 | -------------------------------------------------------------------------------- /inst/res/man_carbon/Manageable_C_Total_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/man_carbon/Manageable_C_Total_2010.tif -------------------------------------------------------------------------------- /inst/res/man_carbon/Manageable_C_Total_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/man_carbon/Manageable_C_Total_2018.tif -------------------------------------------------------------------------------- /inst/res/vul_carbon/Vulnerable_C_Total_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/vul_carbon/Vulnerable_C_Total_2010.tif -------------------------------------------------------------------------------- /inst/res/vul_carbon/Vulnerable_C_Total_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/vul_carbon/Vulnerable_C_Total_2018.tif -------------------------------------------------------------------------------- /inst/res/esalandcover/W080N20_LC100_v3.0.1_2015.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/esalandcover/W080N20_LC100_v3.0.1_2015.tif -------------------------------------------------------------------------------- /inst/res/esalandcover/W080N20_LC100_v3.0.1_2016.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/esalandcover/W080N20_LC100_v3.0.1_2016.tif -------------------------------------------------------------------------------- /inst/res/esalandcover/W080N20_LC100_v3.0.1_2017.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/esalandcover/W080N20_LC100_v3.0.1_2017.tif -------------------------------------------------------------------------------- /inst/res/esalandcover/W080N20_LC100_v3.0.1_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/esalandcover/W080N20_LC100_v3.0.1_2018.tif -------------------------------------------------------------------------------- /inst/res/esalandcover/W080N20_LC100_v3.0.1_2019.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/esalandcover/W080N20_LC100_v3.0.1_2019.tif -------------------------------------------------------------------------------- /inst/res/irr_carbon/Irrecoverable_C_Soil_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/irr_carbon/Irrecoverable_C_Soil_2010.tif -------------------------------------------------------------------------------- /inst/res/irr_carbon/Irrecoverable_C_Soil_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/irr_carbon/Irrecoverable_C_Soil_2018.tif -------------------------------------------------------------------------------- /inst/res/irr_carbon/Irrecoverable_C_Total_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/irr_carbon/Irrecoverable_C_Total_2010.tif -------------------------------------------------------------------------------- /inst/res/irr_carbon/Irrecoverable_C_Total_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/irr_carbon/Irrecoverable_C_Total_2018.tif -------------------------------------------------------------------------------- /inst/res/man_carbon/Manageable_C_Biomass_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/man_carbon/Manageable_C_Biomass_2010.tif -------------------------------------------------------------------------------- /inst/res/man_carbon/Manageable_C_Biomass_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/man_carbon/Manageable_C_Biomass_2018.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220103.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220103.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220110.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220110.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220117.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220117.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220124.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220124.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220131.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220131.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220207.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220207.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220214.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220214.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220221.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220221.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220228.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220228.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220307.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220307.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220314.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220314.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220321.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220321.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220328.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220328.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220404.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220404.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220411.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220411.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220418.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220418.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220425.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220425.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220502.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220502.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220509.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220509.tif -------------------------------------------------------------------------------- /inst/res/nasa_grace/gws_perc_025deg_GL_20220516.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/nasa_grace/gws_perc_025deg_GL_20220516.tif -------------------------------------------------------------------------------- /inst/res/vul_carbon/Vulnerable_C_Biomass_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/vul_carbon/Vulnerable_C_Biomass_2010.tif -------------------------------------------------------------------------------- /inst/res/vul_carbon/Vulnerable_C_Biomass_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/vul_carbon/Vulnerable_C_Biomass_2018.tif -------------------------------------------------------------------------------- /inst/extdata/shell_beach_protected_area_41057_B.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/extdata/shell_beach_protected_area_41057_B.gpkg -------------------------------------------------------------------------------- /inst/res/irr_carbon/Irrecoverable_C_Biomass_2010.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/irr_carbon/Irrecoverable_C_Biomass_2010.tif -------------------------------------------------------------------------------- /inst/res/irr_carbon/Irrecoverable_C_Biomass_2018.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/irr_carbon/Irrecoverable_C_Biomass_2018.tif -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(mapme.biodiversity) 3 | 4 | options(pillar.advice = FALSE) 5 | mapme_options(verbose = FALSE) 6 | test_check("mapme.biodiversity") 7 | -------------------------------------------------------------------------------- /inst/res/gsw_time_series/v5_2000-0000280000-0000480000.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gsw_time_series/v5_2000-0000280000-0000480000.tif -------------------------------------------------------------------------------- /inst/res/gsw_time_series/v5_2001-0000280000-0000480000.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gsw_time_series/v5_2001-0000280000-0000480000.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-01.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-01.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-02.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-02.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-03.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-03.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-04.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-04.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-05.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-05.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-06.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-06.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-07.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-07.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-08.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-08.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-09.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-09.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-10.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-10.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-11.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-11.tif -------------------------------------------------------------------------------- /inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-12.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_precipitation/wc2.1_2.5m_prec_2018-12.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-01.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-01.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-02.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-02.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-03.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-03.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-04.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-04.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-05.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-05.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-06.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-06.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-07.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-07.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-08.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-08.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-09.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-09.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-10.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-10.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-11.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-11.tif -------------------------------------------------------------------------------- /inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-12.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_max_temperature/wc2.1_2.5m_tmax_2018-12.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-01.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-01.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-02.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-02.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-03.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-03.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-04.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-04.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-05.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-05.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-06.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-06.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-07.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-07.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-08.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-08.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-09.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-09.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-10.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-10.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-11.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-11.tif -------------------------------------------------------------------------------- /inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-12.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/worldclim_min_temperature/wc2.1_2.5m_tmin_2018-12.tif -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_treecover_area.md: -------------------------------------------------------------------------------- 1 | # treecover works 2 | 3 | Code 4 | result$value 5 | Output 6 | [1] 2057.330 2056.816 2055.127 2021.265 2011.870 2007.594 7 | 8 | -------------------------------------------------------------------------------- /inst/res/gfw_lossyear/Hansen_GFC-2023-v1.11_lossyear_20N_080W.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gfw_lossyear/Hansen_GFC-2023-v1.11_lossyear_20N_080W.tif -------------------------------------------------------------------------------- /inst/res/global_surface_water_change/change_60W_10Nv1_4_2021.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/global_surface_water_change/change_60W_10Nv1_4_2021.tif -------------------------------------------------------------------------------- /inst/res/gfw_treecover/Hansen_GFC-2023-v1.11_treecover2000_20N_080W.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gfw_treecover/Hansen_GFC-2023-v1.11_treecover2000_20N_080W.tif -------------------------------------------------------------------------------- /inst/res/global_surface_water_occurrence/occurrence_60W_10Nv1_4_2021.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/global_surface_water_occurrence/occurrence_60W_10Nv1_4_2021.tif -------------------------------------------------------------------------------- /inst/res/global_surface_water_recurrence/recurrence_60W_10Nv1_4_2021.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/global_surface_water_recurrence/recurrence_60W_10Nv1_4_2021.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010001.h11v07.061.2021309000505_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010001.h11v07.061.2021309000505_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010032.h11v07.061.2021309000639_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010032.h11v07.061.2021309000639_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010060.h11v07.061.2021309000812_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010060.h11v07.061.2021309000812_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010091.h11v07.061.2021309001013_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010091.h11v07.061.2021309001013_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010121.h11v07.061.2021309001139_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010121.h11v07.061.2021309001139_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010152.h11v07.061.2021309001301_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010152.h11v07.061.2021309001301_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010182.h11v07.061.2021309001436_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010182.h11v07.061.2021309001436_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010213.h11v07.061.2021309001642_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010213.h11v07.061.2021309001642_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010244.h11v07.061.2021309001834_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010244.h11v07.061.2021309001834_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010274.h11v07.061.2021309002047_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010274.h11v07.061.2021309002047_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010305.h11v07.061.2021309002236_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010305.h11v07.061.2021309002236_Burn_Date.tif -------------------------------------------------------------------------------- /inst/res/mcd64a1/MCD64A1.A2010335.h11v07.061.2021309002413_Burn_Date.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/mcd64a1/MCD64A1.A2010335.h11v07.061.2021309002413_Burn_Date.tif -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_treecoverloss_emissions.md: -------------------------------------------------------------------------------- 1 | # emissions works 2 | 3 | Code 4 | result$value 5 | Output 6 | [1] 0.0000 212.5268 619.3609 12932.7655 3676.1357 1731.4164 7 | 8 | -------------------------------------------------------------------------------- /inst/res/global_surface_water_seasonality/seasonality_60W_10Nv1_4_2021.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/global_surface_water_seasonality/seasonality_60W_10Nv1_4_2021.tif -------------------------------------------------------------------------------- /inst/res/global_surface_water_transitions/transitions_60W_10Nv1_4_2021.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/global_surface_water_transitions/transitions_60W_10Nv1_4_2021.tif -------------------------------------------------------------------------------- /inst/res/gfw_emissions/gfw_forest_carbon_gross_emissions_Mg_CO2e_px_20N_080W.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapme-initiative/mapme.biodiversity/HEAD/inst/res/gfw_emissions/gfw_forest_carbon_gross_emissions_Mg_CO2e_px_20N_080W.tif -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_burned_area.md: -------------------------------------------------------------------------------- 1 | # calc_burned_area works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 55.247 7 | [11] 0.000 0.000 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_population_count.md: -------------------------------------------------------------------------------- 1 | # .calc_population_count works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 4030.166 4009.092 4057.395 3969.157 3993.480 4215.225 3756.914 3762.037 7 | [9] 3941.827 4030.299 4146.592 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_temperature_max_wc.md: -------------------------------------------------------------------------------- 1 | # worldclim maximum temperature works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 21.67845 21.71178 22.70271 22.89641 22.28480 23.37369 23.63685 24.61273 7 | [9] 23.96689 23.37729 22.84229 21.71950 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_precipitation_wc.md: -------------------------------------------------------------------------------- 1 | # worldclim precipitation works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 26.36556 25.85101 66.69062 82.51883 330.19525 60.50434 97.28488 7 | [8] 150.38458 217.67076 160.12506 69.11417 24.80346 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_temperature_min_wc.md: -------------------------------------------------------------------------------- 1 | # worldclim minimum temperature works 2 | 3 | Code 4 | result_exact$value 5 | Output 6 | [1] 9.698139 9.585705 10.510759 11.665625 12.585298 14.367579 13.510760 7 | [8] 14.066925 13.585298 13.495863 12.510760 10.627729 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_precipitation_chelsa.md: -------------------------------------------------------------------------------- 1 | # precipitation indicator works 2 | 3 | Code 4 | result$value 5 | Output 6 | [1] 54.806897 8.713793 25.320690 74.609310 185.237241 133.464138 7 | [7] 198.038966 163.655517 171.107241 136.512069 196.805862 42.015517 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/test-get_teow.R: -------------------------------------------------------------------------------- 1 | test_that(".get_teow works", { 2 | skip_on_cran() 3 | 4 | gteow <- get_teow("test.zip") 5 | expect_silent(.check_resource_fun(gteow)) 6 | fps <- gteow() 7 | expect_silent(.check_footprints(fps)) 8 | expect_equal(fps$filename, "wwf_terr_ecos.gpkg") 9 | }) 10 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_treecover_area_and_emissions.md: -------------------------------------------------------------------------------- 1 | # treecover area and emissions works 2 | 3 | Code 4 | result$value 5 | Output 6 | [1] 0.0000 2057.3295 212.5268 2056.8158 619.3609 2055.1275 7 | [7] 12932.7655 2021.2651 3676.1357 2011.8703 1731.4164 2007.5943 8 | 9 | -------------------------------------------------------------------------------- /tests/testthat/test-get_chelsa.R: -------------------------------------------------------------------------------- 1 | test_that("get_chelsa works", { 2 | skip_on_cran() 3 | 4 | expect_error(get_chelsa(1970)) 5 | gc <- get_chelsa(years = 2010) 6 | expect_silent(.check_resource_fun(gc)) 7 | fps <- gc(aoi) 8 | expect_silent(fps <- .check_footprints(fps)) 9 | expect_equal(nrow(fps), 12) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test-get_nasa_grace.R: -------------------------------------------------------------------------------- 1 | test_that(".get_droughtind works", { 2 | skip_on_cran() 3 | 4 | expect_error(get_nasa_grace(2000)) 5 | gng <- get_nasa_grace(years = 2004:2010) 6 | expect_silent(.check_resource_fun(gng)) 7 | expect_silent(fps <- gng()) 8 | expect_silent(.check_footprints(fps)) 9 | expect_equal(nrow(fps), 365) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/calc_drought_indicator.md: -------------------------------------------------------------------------------- 1 | # drought indicator works 2 | 3 | Code 4 | result_exact[[1]]$value 5 | Output 6 | [1] 56.83633 54.39388 52.67265 51.67265 41.95142 53.55755 76.55755 76.55755 7 | [9] 75.83633 62.72123 75.00000 72.99999 61.11510 76.27878 76.00000 76.27878 8 | [17] 95.99999 97.00000 95.99999 95.99999 9 | 10 | -------------------------------------------------------------------------------- /tests/testthat/test-get_nelson_et_al.R: -------------------------------------------------------------------------------- 1 | test_that(".get_nelson_et_al works", { 2 | skip_on_cran() 3 | 4 | expect_error(get_nelson_et_al(ranges = "na")) 5 | gne <- get_nelson_et_al(ranges = "20k_50k") 6 | expect_silent(.check_resource_fun(gne)) 7 | fps <- gne() 8 | expect_silent(.check_footprints(fps)) 9 | expect_equal(fps$filename, "traveltime-20k_50k.tif") 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test-get_gmw.R: -------------------------------------------------------------------------------- 1 | test_that(".get_gmw works", { 2 | skip_on_cran() 3 | 4 | expect_error(get_gmw(2011)) 5 | expect_silent(gmw <- get_gmw(years = 2007:2008)) 6 | expect_silent(.check_resource_fun(gmw)) 7 | expect_silent(fps <- gmw()) 8 | expect_silent(.check_footprints(fps)) 9 | expect_equal(fps$filename, c("gmw_v3_2007_vec.gpkg", "gmw_v3_2008_vec.gpkg")) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test-get_chirps.R: -------------------------------------------------------------------------------- 1 | # This test was deactivated because calls to the CHIRPS website would fail. 2 | # TODO: reactivate this test 3 | # test_that(".get_chirps works", { 4 | # skip_on_cran() 5 | # 6 | # expect_error(get_chirps(1970)) 7 | # gc <- get_chirps(years = 2010) 8 | # expect_silent(.check_resource_fun(gc)) 9 | # fps <- gc(aoi) 10 | # expect_silent(fps <- .check_footprints(fps)) 11 | # expect_equal(nrow(fps), 12) 12 | # }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test-get_gfw_emissions.R: -------------------------------------------------------------------------------- 1 | test_that(".get_gfw_emissions works", { 2 | skip_on_cran() 3 | 4 | x <- read_sf( 5 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 6 | package = "mapme.biodiversity" 7 | ) 8 | ) 9 | .clear_resources() 10 | ge <- get_gfw_emissions() 11 | expect_silent(.check_resource_fun(ge)) 12 | expect_silent(fps <- ge(x)) 13 | expect_silent(.check_footprints(fps)) 14 | expect_equal(fps$filename, "gfw_forest_carbon_gross_emissions_Mg_CO2e_px_20N_080W.tif") 15 | }) 16 | -------------------------------------------------------------------------------- /mapme.biodiversity.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | LineEndingConversion: Posix 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /tests/testthat/test-get_acled.R: -------------------------------------------------------------------------------- 1 | test_that("get_acled works", { 2 | expect_error(get_acled(accept_terms = FALSE), "Terms of Use") 3 | expect_error(expect_message(get_acled(accept_terms = TRUE, email = "")), "email") 4 | expect_error(expect_message(get_acled(accept_terms = TRUE, email = "mymail")), "password") 5 | Sys.setenv(ACLED_EMAIL = "my-mail") 6 | Sys.setenv(ACLED_PASSWORD = "my-key") 7 | expect_no_error(get_acled(accept_terms = TRUE)) 8 | Sys.setenv(ACLED_EMAIL = "") 9 | Sys.setenv(ACLED_PASSWORD = "") 10 | }) 11 | -------------------------------------------------------------------------------- /data-raw/key_biodiversity_areas.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | 3 | aoi <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity") 5 | aoi <- read_sf(aoi) 6 | 7 | sf_use_s2(FALSE) 8 | aoi <- suppressWarnings( 9 | st_simplify(st_buffer(aoi, dist = -0.01), dTolerance = 0.001) 10 | ) 11 | sf_use_s2(TRUE) 12 | aoi [, 1:4] <- NULL 13 | 14 | outdir <- "inst/res/key_biodiversity_areas" 15 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 16 | write_sf(aoi, file.path(outdir, "kbas.gpkg")) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-get_accessibility_2000.R: -------------------------------------------------------------------------------- 1 | test_that(".get_accessibility_2000 works", { 2 | 3 | # Run the function and check that it returns a valid function 4 | ga2000 <- get_accessibility_2000() 5 | expect_silent(.check_resource_fun(ga2000)) 6 | 7 | # Execute the returned function to get the footprint 8 | fps <- ga2000() 9 | 10 | # Check that the footprint is a valid sf object 11 | expect_silent(.check_footprints(fps)) 12 | 13 | # Verify the filename in the returned footprint 14 | expect_equal(fps$filename, "acc_50k.tif") 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test-get_gfw_lossyear.R: -------------------------------------------------------------------------------- 1 | test_that(".get_gfw_lossyear works", { 2 | skip_on_cran() 3 | .clear_resources() 4 | 5 | x <- read_sf( 6 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 7 | package = "mapme.biodiversity" 8 | ) 9 | ) 10 | expect_error(get_gfw_lossyear("na")) 11 | gl <- get_gfw_lossyear() 12 | expect_silent(.check_resource_fun(gl)) 13 | expect_silent(fps <- gl(x)) 14 | expect_silent(.check_footprints(fps)) 15 | expect_equal(fps$filename, "Hansen_GFC-2024-v1.12_lossyear_20N_080W.tif") 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-get_worldpop.R: -------------------------------------------------------------------------------- 1 | test_that(".get_worldpop works", { 2 | skip_on_cran() 3 | .clear_resources() 4 | outdir <- file.path(tempdir(), "mapme.data") 5 | .copy_resource_dir(outdir) 6 | mapme_options(outdir = outdir, verbose = FALSE) 7 | 8 | expect_error(get_worldpop(1999)) 9 | gwp <- get_worldpop(years = 2010) 10 | expect_silent(.check_resource_fun(gwp)) 11 | fps <- gwp(outdir = file.path(outdir, "worldpop")) 12 | expect_silent(.check_footprints(fps)) 13 | expect_equal(fps$filename, "ppp_2010_1km_Aggregated.tif") 14 | }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test-get_nasa_srtm.R: -------------------------------------------------------------------------------- 1 | test_that(".get_nasa_srtm works", { 2 | skip_on_cran() 3 | 4 | x <- read_sf( 5 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 6 | package = "mapme.biodiversity" 7 | ) 8 | ) 9 | 10 | gns <- get_nasa_srtm() 11 | expect_silent(.check_resource_fun(gns)) 12 | fps <- gns(x) 13 | expect_silent(.check_footprints(fps)) 14 | expect_equal(fps$filename, "NASADEM_HGT_n18w072.tif") 15 | x_split <- st_as_sf(st_make_grid(x, n = 2)) 16 | fps <- gns(x_split) 17 | expect_equal(nrow(fps), 1) 18 | }) 19 | -------------------------------------------------------------------------------- /tests/testthat/test-get_fritz_et_al.R: -------------------------------------------------------------------------------- 1 | test_that(".get_fritz_et_al works", { 2 | skip_on_cran() 3 | 4 | expect_error(get_fritz_et_al(resolution = 1)) 5 | gf <- get_fritz_et_al(resolution = 100) 6 | expect_silent(.check_resource_fun(gf)) 7 | suppressWarnings(fps <- gf()) 8 | expect_silent(.check_footprints(fps)) 9 | gf <- get_fritz_et_al(resolution = 1000) 10 | suppressWarnings(fps2 <- gf()) 11 | expect_silent(.check_footprints(fps2)) 12 | expect_equal(fps$filename, "geo_fritz_et_al_100m.tif") 13 | expect_equal(fps2$filename, "geo_fritz_et_al_1000m.tif") 14 | }) 15 | -------------------------------------------------------------------------------- /data-raw/ipbes.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(terra) 3 | library(sf) 4 | 5 | aoi <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 6 | package = "mapme.biodiversity" 7 | ) %>% 8 | read_sf() 9 | 10 | outdir <- tempfile() 11 | dir.create(outdir) 12 | mapme_options(outdir = outdir) 13 | 14 | get_resources(x, get_ipbes_biomes()) 15 | biome <- prep_resources(x)$ipbes_biomes 16 | 17 | writeRaster(biome, 18 | filename = file.path("inst/resources/ipbes_biomes/", paste0(names(biome), ".tif")), 19 | datatype = "INT1U", gdal = c("COMPRESS=LZW"), 20 | overwrite = TRUE 21 | ) 22 | -------------------------------------------------------------------------------- /tests/testthat/test-get_mcd64A1.R: -------------------------------------------------------------------------------- 1 | test_that("get_mcd64a1 works", { 2 | skip_on_cran() 3 | 4 | x <- read_sf( 5 | system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 6 | package = "mapme.biodiversity" 7 | ) 8 | ) 9 | 10 | gmc <- get_mcd64a1(years = 2010) 11 | expect_silent(.check_resource_fun(gmc)) 12 | fps <- gmc(x) 13 | expect_silent(.check_footprints(fps)) 14 | expect_equal(fps$filename[1], "MCD64A1.A2010335.h11v07.061.2021309002413_Burn_Date.tif") 15 | x_split <- st_as_sf(st_make_grid(x, n = 2)) 16 | fps <- gmc(x_split) 17 | expect_equal(nrow(fps), 12) 18 | }) 19 | -------------------------------------------------------------------------------- /data-raw/hfp.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(terra) 3 | library(sf) 4 | 5 | aoi <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 6 | package = "mapme.biodiversity" 7 | ) %>% 8 | read_sf() 9 | 10 | outdir <- tempfile() 11 | dir.create(outdir) 12 | mapme_options(outdir = outdir) 13 | 14 | get_resources(x, get_humanfootprint(years = 2010)) 15 | hfp <- prep_resources(x)$humanfootprint 16 | writeRaster(hfp, 17 | filename = file.path("inst/resources/humanfootprint/", paste0(names(hfp), ".tif")), 18 | datatype = "FLT4S", gdal = c("COMPRESS=LZW"), 19 | overwrite = TRUE 20 | ) 21 | -------------------------------------------------------------------------------- /data-raw/iucn.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(terra) 3 | 4 | x <- read_sf(system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 5 | package = "mapme.biodiversity" 6 | )) 7 | crs <- st_crs("ESRI:54009") 8 | x <- st_transform(x, crs) 9 | r <- rast(x, resolution = 30000, nlyrs = 2) 10 | set.seed(43) 11 | r[] <- round(runif(ncell(r) * nlyr(r), min = 1, max = 30)) 12 | names(r) <- c("Amphibians_SR_2023", "Birds_THR_SR_2023") 13 | outdir <- "inst/res/iucn" 14 | dir.create(outdir, showWarnings = FALSE) 15 | writeRaster(r, 16 | filename = file.path(outdir, paste0(names(r), ".tif")), 17 | datatype = "INT1U", overwrite = TRUE 18 | ) 19 | -------------------------------------------------------------------------------- /data-raw/mcd64a1.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(terra) 3 | library(sf) 4 | 5 | x <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 6 | package = "mapme.biodiversity" 7 | ) 8 | 9 | x <- st_read(x) 10 | mapme_options(outdir = NULL) 11 | get_resources(x, get_mcd64a1(2010)) 12 | mcd64a1 <- prep_resources(x)$mcd64a1 13 | 14 | dir.create("inst/res/mcd64a1/", showWarnings = FALSE) 15 | mcd64a1 <- aggregate(mcd64a1, 4) 16 | writeRaster( 17 | mcd64a1, 18 | file.path("inst/res/mcd64a1/", paste0(names(mcd64a1), ".tif")), 19 | overwrite = TRUE, 20 | gdal = c("COMPRESS=DEFLATE"), 21 | datatype = "INT1U" 22 | ) 23 | -------------------------------------------------------------------------------- /data-raw/fritz_et_al.R: -------------------------------------------------------------------------------- 1 | ## code to prepare `fritz_et_al` dataset goes here 2 | library(mapme.biodiversity) 3 | library(terra) 4 | library(sf) 5 | 6 | tmp_loc <- tempfile() 7 | dir.create(tmp_loc) 8 | x <- read_sf( 9 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 10 | package = "mapme.biodiversity" 11 | ) 12 | ) 13 | mapme_options(outdir = tmp_loc, verbose = FALSE) 14 | get_resources(x, get_fritz_et_al(resolution = 100)) 15 | drivers <- prep_resources(x)[["fritz_et_al"]] 16 | dir.create("inst/res/fritz_et_al", showWarnings = FALSE) 17 | writeRaster(drivers, "inst/res/fritz_et_al/geo_fritz_et_al_100m.tif", 18 | overwrite = TRUE 19 | ) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_hfp.R: -------------------------------------------------------------------------------- 1 | test_that("calc_hfp works", { 2 | x <- read_sf(system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 3 | package = "mapme.biodiversity" 4 | )) 5 | hfp <- rast(system.file("res", "humanfootprint", "hfp2010.tif", 6 | package = "mapme.biodiversity" 7 | )) 8 | hf <- calc_humanfootprint(stats = c("mean", "median")) 9 | expect_silent(result <- hf(x, hfp)) 10 | expect_silent(.check_single_asset(result)) 11 | expect_equal(nrow(result), 2) 12 | expect_equal(result$variable, c("humanfootprint_mean", "humanfootprint_median")) 13 | expect_equal(result$value, c(2.87, 2.62), tolerance = 0.01) 14 | }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_landcover.R: -------------------------------------------------------------------------------- 1 | test_that("esa global landcover works", { 2 | skip_on_cran() 3 | x <- read_sf( 4 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 5 | package = "mapme.biodiversity" 6 | ) 7 | ) 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_esalandcover(years = 2015)) 13 | esalandcover <- prep_resources(x)[["esalandcover"]][[1]] 14 | 15 | cl <- calc_landcover() 16 | expect_true(is.null(cl(x, NULL))) 17 | result <- cl(x, esalandcover) 18 | expect_silent(.check_single_asset(result)) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-get_esalandcover.R: -------------------------------------------------------------------------------- 1 | test_that(".get_esalandcover works", { 2 | skip_on_cran() 3 | x <- read_sf( 4 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 5 | package = "mapme.biodiversity" 6 | ) 7 | ) 8 | 9 | # Add testing attribute in order to skip downloads 10 | expect_error(get_esalandcover(years = 2000)) 11 | gel <- get_esalandcover(years = 2015) 12 | expect_silent(.check_resource_fun(gel)) 13 | fps <- gel(x) 14 | expect_silent(.check_footprints(fps)) 15 | # adds test to check for multiple polygons in the same tile 16 | x_split <- st_as_sf(st_make_grid(x, n = 2)) 17 | fps2 <- gel(x_split) 18 | expect_true(identical(fps, fps2)) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-get_gfw_treecover.R: -------------------------------------------------------------------------------- 1 | test_that(".get_gfw_tile_id works", { 2 | gfw_grid <- make_global_grid() 3 | expect_equal(.get_gfw_tile_id(gfw_grid[100, ]), "20S_110E") 4 | }) 5 | 6 | test_that(".get_gfw_treecover works", { 7 | skip_on_cran() 8 | 9 | x <- read_sf( 10 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 11 | package = "mapme.biodiversity" 12 | ) 13 | ) 14 | expect_error(get_gfw_treecover("na")) 15 | gt <- get_gfw_treecover() 16 | expect_silent(.check_resource_fun(gt)) 17 | expect_silent(fps <- gt(x)) 18 | expect_silent(.check_footprints(fps)) 19 | expect_equal(fps$filename, "Hansen_GFC-2024-v1.12_treecover2000_20N_080W.tif") 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-get_hfp.R: -------------------------------------------------------------------------------- 1 | test_that("get_hfp works", { 2 | .clear_resources() 3 | outdir <- file.path(tempdir(), "mapme.data") 4 | .copy_resource_dir(outdir) 5 | mapme_options(outdir = NULL) 6 | expect_warning(get_humanfootprint(years = 2010), "outdir") 7 | mapme_options(outdir = outdir) 8 | expect_message(get_humanfootprint(years = 1999:2000), "target years") 9 | 10 | skip_on_cran() 11 | skip_if_not(Sys.getenv("USER") == "darius") 12 | ghfp <- get_humanfootprint(years = 2010) 13 | fps <- ghfp(outdir = file.path(outdir, "humanfootprint")) 14 | expect_silent(.check_footprints(fps)) 15 | expect_equal(nrow(fps), 1) 16 | expect_equal(fps$filename, "hfp2010.tif") 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-get_ucdp_ged.R: -------------------------------------------------------------------------------- 1 | # test-get_ucdp_ged.R 2 | test_that(".get_ucdp_ged works", { 3 | skip_on_cran() 4 | 5 | expect_error(get_ucdp_ged(version = "not-available")) 6 | 7 | guc <- get_ucdp_ged(version = "latest") 8 | expect_silent(.check_resource_fun(guc)) 9 | fps <- guc() 10 | expect_silent(.check_footprints(fps)) 11 | expect_equal(fps$filename, "ged241-csv.gpkg") 12 | 13 | guc <- get_ucdp_ged(version = "19.1") 14 | fps <- guc() 15 | expect_equal(fps$filename, "ged191-csv.gpkg") 16 | 17 | expect_equal( 18 | .ucdp_versions(), 19 | c( 20 | "5.0", "17.1", "17.2", "18.1", "19.1", 21 | "20.1", "21.1", "22.1", "23.1", "24.1" 22 | ) 23 | ) 24 | }) 25 | -------------------------------------------------------------------------------- /data-raw/biodiversity_intactness_index.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(terra) 3 | 4 | mapme_options(outdir = NULL) 5 | 6 | x <- read_sf( 7 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 8 | package = "mapme.biodiversity")) %>% 9 | get_resources(get_biodiversity_intactness_index("lbii.asc")) 10 | 11 | bii <- prep_resources(x) 12 | bii <- bii [[1]] 13 | 14 | outdir <- "inst/resources/biodiversity_intactness_index" 15 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 16 | 17 | bii <- mask(bii, x) 18 | writeRaster(bii, file.path(outdir, "lbii.asc")) 19 | file.remove(c(file.path(outdir, "lbii.prj"), 20 | file.path(outdir, "lbii.asc.aux.xml"))) 21 | -------------------------------------------------------------------------------- /data-raw/chelsa.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(terra) 3 | library(sf) 4 | 5 | tmp_loc <- tempfile() 6 | outdir <- "inst/res/chelsa/" 7 | 8 | dir.create(tmp_loc) 9 | x <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 10 | package = "mapme.biodiversity" 11 | ) %>% st_read() 12 | 13 | library(future) 14 | plan(multisession, workers = 6) 15 | get_resources(x, get_chelsa(2010)) 16 | plan(sequential) 17 | chelsa <- prep_resources(x)$chelsa 18 | chelsa <- mask(chelsa, x) 19 | 20 | dir.create(outdir, showWarnings = FALSE) 21 | writeRaster(chelsa, file.path(outdir, paste0(names(chelsa), ".tif")), 22 | overwrite = TRUE, 23 | gdal = c("COMPRESS=LZW", "PREDICTOR=2"), datatype = "INT2U" 24 | ) 25 | -------------------------------------------------------------------------------- /man/check_available_years.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{check_available_years} 4 | \alias{check_available_years} 5 | \title{Helper to check yearly availability} 6 | \usage{ 7 | check_available_years(target_years, available_years, indicator) 8 | } 9 | \arguments{ 10 | \item{target_years}{Numeric indicating the target year.} 11 | 12 | \item{available_years}{Numeric indicating the available years.} 13 | 14 | \item{indicator}{A character vector with target resource/indicator name.} 15 | } 16 | \description{ 17 | Use this function to check if a specified vector of years intersects 18 | with the yearly availability of a resource. 19 | } 20 | \keyword{utils} 21 | -------------------------------------------------------------------------------- /tests/testthat/test-get_soilgrids.R: -------------------------------------------------------------------------------- 1 | test_that("get_soilgrids works", { 2 | skip_on_cran() 3 | skip_if_not(Sys.getenv("USER") == "darius") 4 | 5 | expect_error(get_soilgrids(layers = "na", depths = .sg_depths, stats = .sg_stats)) 6 | expect_error(get_soilgrids(layers = names(.sg_layers), depths = "na", stats = .sg_stats)) 7 | expect_error(get_soilgrids(layers = names(.sg_layers), depths = .sg_depths, stats = "na")) 8 | 9 | gsg <- get_soilgrids(layers = names(.sg_layers)[1], depths = .sg_depths[1], stats = .sg_stats[1]) 10 | expect_silent(.check_resource_fun(gsg)) 11 | suppressWarnings(fps <- gsg()) 12 | expect_silent(.check_footprints(fps)) 13 | expect_equal(fps$filename, "bdod_0-5cm_Q0.05.vrt") 14 | }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_gsw_change.R: -------------------------------------------------------------------------------- 1 | test_that("gsw change works", { 2 | x <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_global_surface_water_change(version = "v1_4_2021")) 13 | gsw_change <- prep_resources(x)[["global_surface_water_change"]][[1]] 14 | 15 | gswc <- calc_gsw_change() 16 | expect_true(is.null(gswc(x, NULL))) 17 | chg <- gswc(x, gsw_change) 18 | expect_silent(.check_single_asset(chg)) 19 | expect_equal(chg$value, 100, tolerance = 1e-4) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_gsw_occurrence.R: -------------------------------------------------------------------------------- 1 | test_that("gsw occurrence works", { 2 | x <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_global_surface_water_occurrence(version = "v1_4_2021")) 13 | gsw_occurrence <- prep_resources(x)[["global_surface_water_occurrence"]][[1]] 14 | 15 | gswo <- calc_gsw_occurrence(min_occurrence = 10) 16 | expect_true(is.null(gswo(x, NULL))) 17 | occ <- gswo(x, gsw_occurrence) 18 | expect_equal(occ$value, 694.159, tolerance = 1e-4) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_gsw_recurrence.R: -------------------------------------------------------------------------------- 1 | test_that("gsw recurrence works", { 2 | x <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_global_surface_water_recurrence(version = "v1_4_2021")) 13 | gsw_recurrence <- prep_resources(x)[["global_surface_water_recurrence"]][[1]] 14 | 15 | gswr <- calc_gsw_recurrence(min_recurrence = 10) 16 | expect_true(is.null(gswr(x, NULL))) 17 | rec <- gswr(x, gsw_recurrence) 18 | expect_equal(rec$value, 719.590, tolerance = 1e-4) 19 | }) 20 | -------------------------------------------------------------------------------- /data-raw/nasa_grace.R: -------------------------------------------------------------------------------- 1 | ## code to prepare `nasa_grace` dataset goes here 2 | library(mapme.biodiversity) 3 | library(terra) 4 | library(sf) 5 | 6 | tmp_loc <- tempfile() 7 | dir.create(tmp_loc) 8 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 9 | package = "mapme.biodiversity" 10 | ) |> st_read() 11 | 12 | mapme_options(outdir = tmp_loc) 13 | 14 | get_resources(aoi, get_nasa_grace(years = 2022)) 15 | tifs <- mapme.biodiversity:::.avail_resources("nasa_grace")[[1]]$location 16 | nasa_grace <- rast(tifs) 17 | nasa_grace_crop <- crop(nasa_grace, aoi) 18 | dir.create("inst/res/nasa_grace/", showWarnings = FALSE) 19 | writeRaster(nasa_grace_crop, file.path("inst/res/nasa_grace/", basename(tifs)), 20 | overwrite = TRUE, gdal = "COMPRESS=LZW", datatype = "INT1U" 21 | ) 22 | -------------------------------------------------------------------------------- /data-raw/ucdp-ged.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(dplyr) 3 | library(tidyr) 4 | library(mapme.biodiversity) 5 | library(rnaturalearth) 6 | 7 | loc <- tempfile() 8 | dir.create(loc) 9 | bur <- ne_countries(country = "Burundi", returnclass = "sf") 10 | mapme_options(outdir = loc) 11 | 12 | get_resources(bur, get_ucdp_ged(version = "22.1")) 13 | ged <- prep_resources(bur)[["ucdp_ged"]][[1]] 14 | ged <- ged %>% filter(year %in% c(1991, 1992)) 15 | ged <- select( 16 | ged, 17 | starts_with("deaths_"), 18 | type_of_violence, 19 | date_prec, 20 | where_prec, 21 | date_start 22 | ) 23 | 24 | dir.create("inst/res/ucdp_ged/", showWarnings = F) 25 | st_write(ged, dsn = "inst/res/ucdp_ged/ged221-csv.gpkg") 26 | st_write(select(bur, sov_a3), dsn = "inst/extdata/burundi.gpkg", delete_dsn = T) 27 | -------------------------------------------------------------------------------- /data-raw/nasa_srtm.R: -------------------------------------------------------------------------------- 1 | ## code to prepare `fritz_et_al` dataset goes here 2 | library(mapme.biodiversity) 3 | library(terra) 4 | library(sf) 5 | 6 | tmp_loc <- tempfile() 7 | dir.create(tmp_loc) 8 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 9 | package = "mapme.biodiversity" 10 | ) %>% st_read() 11 | 12 | attr(aoi, "testing") <- FALSE 13 | tif <- mapme.biodiversity:::.get_nasa_srtm(aoi, download_srtm = TRUE, rundir = tmp_loc) 14 | elevation <- rast(tif) 15 | elevation_crop <- crop(elevation, aoi) 16 | dir.create("inst/res/nasa_srtm/", showWarnings = FALSE) 17 | elevation_crop <- aggregate(elevation_crop, 4) 18 | writeRaster(elevation_crop, file.path("inst/res/nasa_srtm/", basename(tif)), 19 | overwrite = TRUE, gdal = c("COMPRESS=LZW", "PREDICTOR=2"), datatype = "INT2U" 20 | ) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_mangroves_area.R: -------------------------------------------------------------------------------- 1 | test_that("mangrove extent works", { 2 | x <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_gmw(years = c(1996, 2016))) 12 | gmw <- prep_resources(x)[["gmw"]] 13 | 14 | ma <- calc_mangroves_area() 15 | expect_true(is.null(ma(x, NULL))) 16 | result <- ma(x, gmw) 17 | expect_equal(unique(result$variable), "mangroves") 18 | expect_equal(result$value, c(1214.88, 1206.61), tolerance = 1e-4) 19 | expect_equal(format(result$datetime, "%Y"), c("1996", "2016")) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_biome.R: -------------------------------------------------------------------------------- 1 | test_that("biome computation works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_teow("test.zip")) 12 | teow <- prep_resources(x)[["teow"]] 13 | 14 | cb <- calc_biome() 15 | result <- cb(x, teow) 16 | expect_silent(.check_single_asset(result)) 17 | expect_equal(result$value, 18352.24, tolerance = 1e-4) 18 | # check NULL is returned for 0-length tibbles 19 | st_geometry(x) <- st_geometry(x) + 5 20 | st_crs(x) <- st_crs(4326) 21 | expect_equal(cb(x, teow), NULL) 22 | }) 23 | -------------------------------------------------------------------------------- /R/mapme.biodiversity-pkg.R: -------------------------------------------------------------------------------- 1 | #' mapme.biodiversity 2 | #' 3 | #' @name mapme.biodiversity - package 4 | #' @docType package 5 | #' @title mapme.biodiversity - Global biodiversity portfolio analysis 6 | #' @import sf terra 7 | #' @importFrom tibble tibble as_tibble 8 | #' @importFrom magrittr "%>%" 9 | #' @importFrom utils download.file 10 | #' @noRd 11 | #' @keywords internal 12 | globalVariables(c(":=", "!!", ".id", ".", "datetime", "variable", "unit", "value")) 13 | NULL 14 | 15 | 16 | .copy_resource_dir <- function(target) { 17 | if (!dir.exists(target)) { 18 | dir.create(target, showWarnings = FALSE) 19 | resource_dir <- system.file("res", package = "mapme.biodiversity") 20 | for (dir in list.dirs(resource_dir)) { 21 | file.copy(dir, target, recursive = TRUE) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /data-raw/chirps.R: -------------------------------------------------------------------------------- 1 | ## code to prepare `fritz_et_al` dataset goes here 2 | library(mapme.biodiversity) 3 | library(terra) 4 | library(sf) 5 | 6 | tmp_loc <- tempfile() 7 | outdir <- "inst/res/chirps/" 8 | 9 | dir.create(tmp_loc) 10 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 11 | package = "mapme.biodiversity" 12 | ) %>% st_read() 13 | 14 | gch <- get_chirps(years = 2010) 15 | tifs <- gch(aoi, outdir = tmp_loc) 16 | chirps <- lapply(tifs, function(x) rast(x) %>% crop(aoi)) %>% rast() 17 | archives <- list.files(tmp_loc, pattern = "*.gz$") 18 | 19 | dir.create(outdir, showWarnings = FALSE) 20 | writeRaster(chirps, file.path(outdir, basename(tifs)), 21 | overwrite = TRUE, 22 | gdal = c("COMPRESS=LZW", "PREDICTOR=2"), datatype = "INT2U" 23 | ) 24 | file.create(file.path(outdir, archives)) 25 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_ecoregion.R: -------------------------------------------------------------------------------- 1 | test_that("ecoregion computation works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_teow("test.zip")) 13 | teow <- prep_resources(x)[["teow"]] 14 | 15 | ce <- calc_ecoregion() 16 | result <- ce(x, teow) 17 | expect_silent(.check_single_asset(result)) 18 | expect_equal(result$value, 18352.24, tolerance = 1e-4) 19 | 20 | # check NA is returned for 0-length tibbles 21 | st_geometry(x) <- st_geometry(x) + 5 22 | st_crs(x) <- st_crs(4326) 23 | expect_equal(ce(x, teow), NULL) 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat/test-get_iucn.R: -------------------------------------------------------------------------------- 1 | test_that("get_iucn works", { 2 | iucn_dir <- system.file("res", "iucn", package = "mapme.biodiversity") 3 | iucn_files <- list.files(iucn_dir, pattern = "_SR_", full.names = TRUE) 4 | 5 | msg <- "Expecting paths to point towards existing GTiff files." 6 | expect_error(get_iucn(NULL), msg) 7 | expect_error(get_iucn("does-not-exist.tif"), msg) 8 | gpkg <- system.file("extdata", "burundi.gpkg", package = "mapme.biodiversity") 9 | expect_error(get_iucn(gpkg), msg) 10 | other_tif <- system.file("extdata", "burundi_worldpop.tif", package = "mapme.biodiversity") 11 | msg <- "Filenames do match expected schema for IUCN species richness rasters." 12 | expect_error(get_iucn(c(iucn_files, other_tif)), msg) 13 | fps <- get_iucn(iucn_files)() 14 | expect_silent(.check_footprints(fps)) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_gsw_seasonality.R: -------------------------------------------------------------------------------- 1 | test_that("gsw seasonality works", { 2 | x <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_global_surface_water_seasonality(version = "v1_4_2021")) 13 | gsw_seasonality <- prep_resources(x)[["global_surface_water_seasonality"]][[1]] 14 | 15 | gsws <- calc_gsw_seasonality() 16 | expect_true(is.null(gsws(x, NULL))) 17 | season <- gsws(x, gsw_seasonality) 18 | expect_equal(season$value, 19 | c(2514.759, 22.461, 18.045, 23.831, 19.872, 2.512, 0.152, 0, 0, 0, 0, 0, 617.104), 20 | tolerance = 1e-3 21 | ) 22 | }) 23 | -------------------------------------------------------------------------------- /man/check_namespace.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{check_namespace} 4 | \alias{check_namespace} 5 | \title{Checks if namespace is available} 6 | \usage{ 7 | check_namespace(pkg, error = TRUE) 8 | } 9 | \arguments{ 10 | \item{pkg}{A character vector of length one indicating a package name 11 | for which the namespace is tested} 12 | 13 | \item{error}{A logical indicating whether or not to promote missing namespace 14 | to error. If FALSE, a warning is emitted.} 15 | } 16 | \value{ 17 | TRUE, invisible, if the namespace is available. An error message 18 | if \code{error = TRUE}, FALSE and a warning otherwise. 19 | } 20 | \description{ 21 | Use this function if your resource/indicator function requires the 22 | namespace of a certain package to be available. An informative error/warning 23 | message is printed if that is not the case. 24 | } 25 | \keyword{utils} 26 | -------------------------------------------------------------------------------- /man/nasa_grace.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_nasa_grace.R 3 | \name{nasa_grace} 4 | \alias{nasa_grace} 5 | \alias{get_nasa_grace} 6 | \title{NASA GRACE-based Drought Indicator layer} 7 | \usage{ 8 | get_nasa_grace(years = 2003:2022) 9 | } 10 | \arguments{ 11 | \item{years}{A numeric vector indicating the years for which to make the 12 | resource available.} 13 | } 14 | \value{ 15 | A function that returns an \code{sf} footprint object. 16 | } 17 | \description{ 18 | The resource is published by NASA GRACE Tellus. This data set 19 | reflects on potential drought conditions in the shallow groundwater section 20 | relative to a reference period spanning from 1948 to 2012. 21 | It is available as a global raster with a weekly temporal resolution starting 22 | with the year 2003. The value indicates the wetness percentile of a given 23 | pixel with regard to the reference period. 24 | } 25 | \keyword{resource} 26 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 17 | FIGSHARE_PAT: ${{ secrets.FIGSHARE_PAT }} 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - uses: r-lib/actions/setup-r@v2 23 | with: 24 | use-public-rspm: true 25 | 26 | - uses: r-lib/actions/setup-r-dependencies@v2 27 | with: 28 | extra-packages: covr 29 | 30 | - name: Test coverage 31 | run: covr::codecov() 32 | shell: Rscript {0} 33 | -------------------------------------------------------------------------------- /man/nasa_srtm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_nasa_srtm.R 3 | \name{nasa_srtm} 4 | \alias{nasa_srtm} 5 | \alias{get_nasa_srtm} 6 | \title{NASADEM HGT v001} 7 | \source{ 8 | \url{https://planetarycomputer.microsoft.com/dataset/nasadem} 9 | } 10 | \usage{ 11 | get_nasa_srtm() 12 | } 13 | \value{ 14 | A function that returns an \code{sf} footprint object. 15 | } 16 | \description{ 17 | This resource is processed by the Land Processes Distributed Active Archive 18 | Center (LP DAAC) and made available at the Microsoft Planetery Computer. 19 | NASADEM are distributed in 1 degree latitude by 1 degree longitude tiles and 20 | consist of all land between 60° N and 56° S latitude. This accounts for about 21 | 80\% of Earth’s total landmass. 22 | } 23 | \references{ 24 | NASA JPL (2020). NASADEM Merged DEM Global 1 arc second V001. 25 | NASA EOSDIS Land Processes DAAC. Accessed 2023-07-01 from 26 | \doi{doi:10.5067/MEaSUREs/NASADEM/NASADEM_HGT.001} 27 | } 28 | \keyword{resource} 29 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_deforestation_drivers.R: -------------------------------------------------------------------------------- 1 | test_that("deforestation drivers works", { 2 | skip_on_cran() 3 | x <- read_sf( 4 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 5 | package = "mapme.biodiversity" 6 | ) 7 | ) 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | suppressWarnings(get_resources(x, get_fritz_et_al(resolution = 100))) 13 | drivers <- prep_resources(x)[["fritz_et_al"]] 14 | 15 | cdf <- calc_deforestation_drivers() 16 | result <- cdf(x, drivers) 17 | expect_silent(.check_single_asset(result)) 18 | expect_equal( 19 | unique(result$variable), 20 | c( 21 | "commercial_agriculture", "commercial_oil_palm", "managed_forests", 22 | "mining", "natural_disturbances", "pasture", "roads", "wildfire", 23 | "other_subsistance_agriculture", "shifting_cultivation" 24 | ) 25 | ) 26 | expect_equal(sum(result$value), 16809, tolerance = 1e-4) 27 | }) 28 | -------------------------------------------------------------------------------- /data-raw/gsw_time_series.R: -------------------------------------------------------------------------------- 1 | library(dplyr) 2 | library(mapme.biodiversity) 3 | library(sf) 4 | library(terra) 5 | 6 | years <- 2000:2001 7 | 8 | aoi <- read_sf( 9 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 10 | package = "mapme.biodiversity" 11 | ) 12 | ) 13 | x <- get_resources(aoi, get_gsw_time_series(years = years)) 14 | 15 | gsw_time_series <- prep_resources(x) 16 | gsw_time_series <- gsw_time_series [[1]] 17 | 18 | outdir <- "inst/res/gsw_time_series" 19 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 20 | 21 | gsw_time_series <- mask(gsw_time_series, x) 22 | 23 | for(lyr_id in seq_len(nlyr(gsw_time_series))) { 24 | lyr_name <- names(gsw_time_series) [lyr_id] 25 | lyr_name <- sub("VER5-0_yearlyClassification", "v5_", lyr_name) 26 | fname <- paste0(file.path(outdir, lyr_name), ".tif") 27 | lyr_subset <- subset(gsw_time_series, lyr_id) 28 | writeRaster(lyr_subset, fname, 29 | gdal = c("COMPRESS=LZW", "PREDICTOR=2"), datatype = "INT1U", 30 | overwrite = TRUE) 31 | } 32 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_biodiversity_intactness_index.R: -------------------------------------------------------------------------------- 1 | test_that("biodiversity intactness index works", { 2 | x <- read_sf(system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 3 | package = "mapme.biodiversity")) 4 | .clear_resources() 5 | outdir <- file.path(tempdir(), "mapme.data") 6 | .copy_resource_dir(outdir) 7 | mapme_options(outdir = outdir, verbose = FALSE) 8 | 9 | lbii <- system.file("res", "biodiversity_intactness_index", "lbii.asc", 10 | package = "mapme.biodiversity") 11 | get_resources(x, get_biodiversity_intactness_index(lbii)) 12 | bii <- prep_resources(x)[["biodiversity_intactness_index"]] 13 | bi <- calc_biodiversity_intactness_index() 14 | 15 | expect_null( 16 | bi(x, biodiversity_intactness_index = NULL) 17 | ) 18 | expect_silent(result <- bi(x, bii)) 19 | expect_silent(.check_single_asset(result)) 20 | expect_equal(nrow(result), 1) 21 | expect_equal(result$variable, "biodiversity_intactness_index") 22 | expect_equal(result$value, 0.91, tolerance = 0.01) 23 | }) 24 | 25 | -------------------------------------------------------------------------------- /man/accessibility_2000.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_accessibility_2000.R 3 | \name{accessibility_2000} 4 | \alias{accessibility_2000} 5 | \alias{get_accessibility_2000} 6 | \title{Accessibility to Cities in 2000} 7 | \source{ 8 | https://forobs.jrc.ec.europa.eu/gam 9 | } 10 | \usage{ 11 | get_accessibility_2000() 12 | } 13 | \value{ 14 | A function that returns an \code{sf} footprint object. 15 | } 16 | \description{ 17 | This resource provides global maps of travel time to cities of 50,000 or more 18 | people in year 2000. Accessibility refers to the ease with which larger cities can be reached from 19 | a certain location. This dataset represents travel time to major cities globally 20 | as of the year 2000, encoded in minutes. The data is essential for historical 21 | analyses, such as understanding the impact of accessibility on land use and 22 | socio-economic outcomes during this period. 23 | } 24 | \references{ 25 | European Commission, Joint Research Centre (JRC), Global Accessibility Maps (GAM), 2000. 26 | } 27 | \keyword{resource} 28 | -------------------------------------------------------------------------------- /man/make_global_grid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{make_global_grid} 4 | \alias{make_global_grid} 5 | \title{Helper to create a grid of regular resolution and CRS} 6 | \usage{ 7 | make_global_grid( 8 | xmin = -180, 9 | xmax = 170, 10 | dx = 10, 11 | ymin = -50, 12 | ymax = 80, 13 | dy = 10, 14 | proj = NULL 15 | ) 16 | } 17 | \arguments{ 18 | \item{xmin}{minimum longitude value (E/W)} 19 | 20 | \item{xmax}{maximum longitude value (E/W)} 21 | 22 | \item{dx}{difference in longitude value per grid} 23 | 24 | \item{ymin}{minimum latitude value (S/N)} 25 | 26 | \item{ymax}{maximum latitude value (E/W)} 27 | 28 | \item{dy}{difference in latitude value per grid} 29 | 30 | \item{proj}{projection system} 31 | } 32 | \value{ 33 | An sf object with a defined grid. 34 | } 35 | \description{ 36 | Use this function to create a regular grid in a custom CRS. This is used 37 | e.g. to create the tile grid for Global Forest Watch in order to retrieve 38 | the intersecting tiles with a given portfolio. 39 | } 40 | \keyword{utils} 41 | -------------------------------------------------------------------------------- /tests/testthat/test-get_key_biodiversity_areas.R: -------------------------------------------------------------------------------- 1 | test_that("get_key_biodiversity_areas works", { 2 | sample_path <- system.file("extdata", "sierra_de_neiba_478140.gpkg", 3 | package = "mapme.biodiversity" 4 | ) 5 | aoi <- read_sf(sample_path) 6 | aoi <- suppressWarnings(st_cast(aoi, to = "POLYGON")[1, ]) 7 | 8 | expect_error( 9 | get_resources(aoi, get_key_biodiversity_areas()), 10 | "Expecting path to point towards an existing file." 11 | ) 12 | expect_error( 13 | get_resources(aoi, get_key_biodiversity_areas("")), 14 | "Expecting path to point towards an existing file." 15 | ) 16 | expect_error( 17 | get_resources(aoi, get_key_biodiversity_areas(NULL)), 18 | "Expecting path to point towards an existing file." 19 | ) 20 | expect_error( 21 | get_key_biodiversity_areas(path = "inst/resources/"), 22 | "Expecting path to point towards an existing file." 23 | ) 24 | 25 | res <- get_resources(aoi, get_key_biodiversity_areas(sample_path)) 26 | expect_equal( 27 | names(prep_resources(res)), 28 | "key_biodiversity_areas" 29 | ) 30 | }) 31 | -------------------------------------------------------------------------------- /data-raw/gsw.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(sf) 3 | library(terra) 4 | 5 | shp <- read_sf( 6 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 7 | package = "mapme.biodiversity" 8 | ) 9 | ) 10 | outdir_base <- file.path("inst", "res") 11 | 12 | for(gsw_statistic in mapme.biodiversity:::.gsw_statistics) { 13 | 14 | gsw_getter <- sprintf("get_global_surface_water_%s", gsw_statistic) 15 | res <- get_resources(shp, get(gsw_getter)()) 16 | gsw_raster <- prep_resources(res)[[sprintf("global_surface_water_%s", gsw_statistic)]] 17 | 18 | gsw_raster_subset <- crop(gsw_raster, shp) 19 | gsw_raster_subset <- mask(gsw_raster_subset, shp) 20 | 21 | outdir_statistic <- file.path(outdir_base, paste0("global_surface_water_", gsw_statistic)) 22 | dir.create(outdir_statistic, recursive = TRUE, showWarnings = FALSE) 23 | 24 | writeRaster(gsw_raster_subset, 25 | file.path(outdir_statistic, paste0(names(gsw_raster), ".tif")), 26 | gdal = c("COMPRESS=LZW", "PREDICTOR=2"), datatype = "INT1U", 27 | overwrite = TRUE) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /tests/testthat/test-get_biodiversity_intactness_index.R: -------------------------------------------------------------------------------- 1 | test_that("get_biodiversity_intactness_index works", { 2 | sample_path <- system.file("extdata", 3 | "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity") 5 | 6 | expect_error( 7 | get_biodiversity_intactness_index(NULL), 8 | "Expecting path to point towards an existing '.asc' file." 9 | ) 10 | expect_error( 11 | get_biodiversity_intactness_index(), 12 | "Expecting path to point towards an existing '.asc' file." 13 | ) 14 | expect_error( 15 | get_biodiversity_intactness_index(sample_path), 16 | "Expecting path to point towards an existing '.asc' file." 17 | ) 18 | 19 | x <- read_sf(sample_path) 20 | fname_bii <- system.file("res", "biodiversity_intactness_index/lbii.asc", 21 | package = "mapme.biodiversity") 22 | bii <- get_resources(x, 23 | get_biodiversity_intactness_index(fname_bii) 24 | ) 25 | expect_equal( 26 | names(prep_resources(bii)), 27 | "biodiversity_intactness_index" 28 | ) 29 | }) 30 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^renv$ 2 | ^renv\.lock$ 3 | ^mapme\.biodiversity\.Rproj$ 4 | ^\.Rproj\.user$ 5 | ^LICENSE\.md$ 6 | devel 7 | ^\.github$ 8 | ^\.pre-commit-config\.yaml$ 9 | ^_pkgdown\.yml$ 10 | ^docs$ 11 | ^pkgdown$ 12 | inst/tmp/terra 13 | inst/res/chirps/tileindex_chirps.gpkg 14 | inst/res/greenhouse/tileindex_greenhouse.gpkg 15 | inst/res/lossyear/tileindex_lossyear.gpkg 16 | inst/res/treecover2000/tileindex_treecover2000.gpkg 17 | inst/res/worlpop/tileindex_worldpop.gpkg 18 | inst/rest/traveltime/tileindex_traveltime.gpkg 19 | inst/res/srtmdem/tileindex_srtmdem.gpkg 20 | inst/res/soilgrids/tileindex_soilgrids.gpkg 21 | inst/res/precipitation/tileindex_precipitation.gpkg 22 | inst/res/nasagrace/tileindex_nasagrace.gpkg 23 | inst/res/mintemperature/tileindex_mintemperature.gpkg 24 | inst/res/maxtemperature/tileindex_maxtemperature.gpkg 25 | inst/res/esalandcover/tileindex_esalandcover.gpkg 26 | ^README\.Rmd$ 27 | vignettes/workflow.Rmd 28 | vignettes/introduction.Rmd 29 | vignettes/installation.Rmd 30 | vignettes/contributing.Rmd 31 | vignettes/nasa-firms.Rmd 32 | vignettes/output-wide.Rmd 33 | vignettes/assets 34 | ^cran-comments\.md$ 35 | ^CRAN-SUBMISSION$ 36 | ^data-raw$ 37 | ^extras$ 38 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # All available hooks: https://pre-commit.com/hooks.html 2 | # R specific hooks: https://github.com/lorenzwalthert/precommit 3 | repos: 4 | - repo: https://github.com/lorenzwalthert/precommit 5 | rev: v0.4.3 6 | hooks: 7 | - id: style-files 8 | args: [--style_pkg=styler, --style_fun=tidyverse_style] 9 | exclude: > 10 | tests/testthat/_snaps/.* 11 | - id: use-tidy-description 12 | - id: lintr 13 | args: [--warn_only] 14 | verbose: true 15 | - id: readme-rmd-rendered 16 | - id: parsable-R 17 | - id: no-browser-statement 18 | - id: no-debug-statement 19 | - id: deps-in-desc 20 | - repo: https://github.com/pre-commit/pre-commit-hooks 21 | rev: v4.6.0 22 | hooks: 23 | - id: check-added-large-files 24 | args: ['--maxkb=2000'] 25 | - repo: local 26 | hooks: 27 | - id: forbid-to-commit 28 | name: Don't commit common R artifacts 29 | entry: Cannot commit .Rhistory, .RData, .Rds or .rds. 30 | language: fail 31 | files: '\.Rhistory|\.RData|\.Rds|\.rds$' 32 | # `exclude: ` to allow committing specific files 33 | -------------------------------------------------------------------------------- /man/worldpop.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_worldpop.R 3 | \docType{data} 4 | \name{worldpop} 5 | \alias{worldpop} 6 | \alias{get_worldpop} 7 | \title{Population Count layer for year 2000-2020} 8 | \source{ 9 | \url{https://www.worldpop.org/} 10 | } 11 | \usage{ 12 | get_worldpop(years = 2000) 13 | } 14 | \arguments{ 15 | \item{years}{A numeric vector indicating the years for which to make the 16 | resource available.} 17 | } 18 | \value{ 19 | A function that returns an \code{sf} footprint object. 20 | } 21 | \description{ 22 | This resource is published by open spatial demographic data and research 23 | organization called WorldPop. This resource represents the population 24 | count, 1 km spatial resolution layers available to download from the year 25 | 2000 to 2020. The dataset is called as WorldPop Unconstrained Global Mosaics. 26 | The encoded cell value represents the total number of people in that particular 27 | grid cell. 28 | } 29 | \details{ 30 | It may be required to increase the timeout option to successfully download 31 | theses WorldPop layers from their source location via e.g. 32 | \code{options(timeout = 600)}. 33 | } 34 | \keyword{resource} 35 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_burned_area.R: -------------------------------------------------------------------------------- 1 | test_that("calc_burned_area works", { 2 | skip_on_cran() 3 | x <- read_sf( 4 | system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 5 | package = "mapme.biodiversity" 6 | ) 7 | ) 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_mcd64a1(years = 2010)) 13 | mcd64a1 <- prep_resources(x)[["mcd64a1"]] 14 | 15 | ba <- calc_burned_area() 16 | expect_true(is.null(ba(x, NULL))) 17 | result <- ba(x, mcd64a1) 18 | ba <- calc_burned_area(engine = "zonal") 19 | result_zonal <- ba(x, mcd64a1) 20 | ba <- calc_burned_area(engine = "extract") 21 | result_extract <- ba(x, mcd64a1) 22 | ba <- calc_burned_area(engine = "exactextract") 23 | result_exact <- ba(x, mcd64a1) 24 | 25 | expect_silent(.check_single_asset(result)) 26 | expect_silent(.check_single_asset(result_zonal)) 27 | expect_silent(.check_single_asset(result_extract)) 28 | expect_silent(.check_single_asset(result_exact)) 29 | 30 | expect_equal(result_zonal$value, result_zonal$value, tolerance = 1e-4) 31 | expect_snapshot(result_exact$value) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test-ipbes.R: -------------------------------------------------------------------------------- 1 | test_that("get_ipbes_biomes works", { 2 | skip_on_cran() 3 | skip_if_not(Sys.getenv("USER") == "darius") 4 | gib <- get_ipbes_biomes() 5 | expect_silent(fps <- gib()) 6 | expect_silent(.check_footprints(fps)) 7 | expect_equal(fps$filename, "IPBES_UoA_biomes_JK.tif") 8 | }) 9 | 10 | test_that("calc_ipbes_biomes works", { 11 | skip_on_cran() 12 | x <- read_sf(system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 13 | package = "mapme.biodiversity" 14 | )) 15 | .clear_resources() 16 | outdir <- file.path(tempdir(), "mapme.data") 17 | .copy_resource_dir(outdir) 18 | mapme_options(outdir = outdir, verbose = FALSE) 19 | 20 | f <- file.path(outdir, "res", "ipbes_biomes", "IPBES_UoA_biomes_JK.tif") 21 | ipbes <- rast(f) 22 | ib <- calc_ipbes_biomes() 23 | 24 | expect_equal(ib(x, NULL), NULL) 25 | expect_silent(result <- ib(x, ipbes)) 26 | expect_true(inherits(result, "list")) 27 | result <- result[[1]] 28 | expect_silent(.check_single_asset(result)) 29 | expect_equal(result$value, c(1184.2016, 1988.4815), tolerance = 0.01) 30 | vars <- c("tropical_and_subtropical_dry_and_humid_forests", "shelf_ecosystems") 31 | expect_equal(result$variable, vars) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_gsw_transitions.R: -------------------------------------------------------------------------------- 1 | test_that("gsw transitions works", { 2 | x <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_global_surface_water_transitions(version = "v1_4_2021")) 13 | gsw_transitions <- prep_resources(x)[["global_surface_water_transitions"]][[1]] 14 | 15 | gswt <- calc_gsw_transitions() 16 | expect_true(is.null(gswt(x, NULL))) 17 | transitions <- gswt(x, gsw_transitions) 18 | expect_silent(.check_single_asset(transitions)) 19 | 20 | transitions_expected <- tibble( 21 | class = c( 22 | "Permanent", "New Permanent", "Lost Permanent", "Seasonal", 23 | "New Seasonal", "Seasonal to Permanent", "Permanent to Seasonal", 24 | "Ephemeral Permanent", "Ephemeral Seasonal" 25 | ), 26 | area = c( 27 | 199.40, 388.84, 0.38, 28 | 1.90, 83.90, 28.859, 29 | 1.06, 0.60, 21.62 30 | ) 31 | ) 32 | expect_equal(transitions$value, transitions_expected$area, tolerance = 1e-4) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_iucn.R: -------------------------------------------------------------------------------- 1 | test_that("calc_species_richness works", { 2 | x <- read_sf(system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 3 | package = "mapme.biodiversity" 4 | )) 5 | .clear_resources() 6 | outdir <- file.path(tempdir(), "mapme.data") 7 | .copy_resource_dir(outdir) 8 | mapme_options(outdir = outdir, verbose = FALSE) 9 | 10 | iucn_dir <- system.file("res", "iucn", package = "mapme.biodiversity") 11 | iucn_files <- list.files(iucn_dir, pattern = "_SR_", full.names = TRUE) 12 | 13 | get_resources(x, get_iucn(iucn_files)) 14 | iucn <- prep_resources(x)[["iucn"]] 15 | 16 | expect_error(calc_species_richness(engine = "other")) 17 | expect_error(calc_species_richness(stats = "other")) 18 | 19 | csr <- calc_species_richness(stats = "median") 20 | expect_equal(csr(x, NULL), NULL) 21 | iucnNA <- iucn 22 | iucnNA[] <- NA 23 | expect_equal(csr(x, iucnNA), NULL) 24 | 25 | expect_silent(result <- csr(x, iucn)) 26 | expect_silent(.check_single_asset(result)) 27 | expect_equal(nrow(result), 2) 28 | vars <- c("amphibians_sr_2023_median", "birds_thr_sr_2023_median") 29 | expect_equal(unique(result$variable), vars) 30 | vals <- c(15, 27) 31 | expect_equal(result$value, vals) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test-get_carbon.R: -------------------------------------------------------------------------------- 1 | test_that("get_carbon works", { 2 | skip_on_cran() 3 | outdir <- file.path(tempdir(), "mapme.data") 4 | .copy_resource_dir(outdir) 5 | 6 | mapme_options(outdir = NULL) 7 | expect_warning(get_irr_carbon()) 8 | expect_warning(get_man_carbon()) 9 | expect_warning(get_vul_carbon()) 10 | 11 | mapme_options(outdir = outdir) 12 | gca <- get_irr_carbon() 13 | fps <- gca(outdir = file.path(outdir, "irr_carbon")) 14 | expect_silent(.check_footprints(fps)) 15 | expect_equal(nrow(fps), 6) 16 | 17 | gca <- get_man_carbon() 18 | fps <- gca(outdir = file.path(outdir, "man_carbon")) 19 | expect_silent(.check_footprints(fps)) 20 | expect_equal(nrow(fps), 6) 21 | 22 | gca <- get_vul_carbon() 23 | fps <- gca(outdir = file.path(outdir, "vul_carbon")) 24 | expect_silent(.check_footprints(fps)) 25 | expect_equal(nrow(fps), 6) 26 | }) 27 | 28 | test_that(".get_goldstein_url works", { 29 | skip_on_cran() 30 | skip_if_not(Sys.getenv("USER") == "darius") 31 | expect_silent(result <- .get_goldstein_url("Irrecoverable")) 32 | expect_equal(nrow(result), 2) 33 | filenames <- c("Irrecoverable_Carbon_2010.zip", "Irrecoverable_Carbon_2018.zip") 34 | expect_equal(result$filename, filenames) 35 | }) 36 | -------------------------------------------------------------------------------- /data-raw/accessibility_2000.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(terra) 3 | library(mapme.biodiversity) 4 | 5 | # Load the spatial object (x) for cropping 6 | x <- read_sf(system.file("extdata", "sierra_de_neiba_478140.gpkg", package = "mapme.biodiversity")) 7 | 8 | # Set output directory for cropped data 9 | outdir <- "inst/res/accessibility_2000" 10 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 11 | 12 | # Set the temporary directory for processing 13 | tmp_loc <- tempfile() 14 | dir.create(tmp_loc) 15 | mapme_options(outdir = tmp_loc) 16 | 17 | # Download and process the full accessibility data 18 | get_resources(x, get_accessibility_2000()) 19 | resources <- prep_resources(x) 20 | 21 | # Crop the accessibility data to the extent of x 22 | access_raster <- resources$accessibility_2000 23 | 24 | # Save the cropped raster in the package inst/resources directory 25 | writeRaster(access_raster, 26 | filename = file.path(outdir, "acc_50k.tif"), 27 | datatype = "INT4S", 28 | overwrite = TRUE, 29 | wopt = list(gdal = c("COMPRESS=LZW", 30 | "BLOCKXSIZE=128", 31 | "BLOCKYSIZE=128", 32 | "TILED=YES")) 33 | ) 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Default GitHub .gitignore for R 2 | 3 | # History files 4 | .Rhistory 5 | .Rapp.history 6 | 7 | # Session Data files 8 | .RData 9 | .RDataTmp 10 | 11 | # User-specific files 12 | .Ruserdata 13 | 14 | # Example code in package build process 15 | *-Ex.R 16 | 17 | # Output files from R CMD build 18 | /*.tar.gz 19 | 20 | # Output files from R CMD check 21 | /*.Rcheck/ 22 | 23 | # RStudio files 24 | .Rproj.user/ 25 | 26 | # produced vignettes 27 | vignettes/*.html 28 | vignettes/*.pdf 29 | 30 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 31 | .httr-oauth 32 | 33 | # knitr and R markdown default cache directories 34 | *_cache/ 35 | /cache/ 36 | 37 | # Temporary files created by R markdown 38 | *.utf8.md 39 | *.knit.md 40 | 41 | # R Environment Variables 42 | .Renviron 43 | 44 | # pkgdown site 45 | docs/ 46 | 47 | # translation temp files 48 | po/*~ 49 | 50 | # RStudio Connect folder 51 | rsconnect/ 52 | 53 | ## Add any custom .gitignore items below 54 | 55 | # folder with development related stuff 56 | develop 57 | 58 | # renv related files and folders 59 | renv.lock 60 | renv/ 61 | 62 | # installed doc folder 63 | inst/doc 64 | 65 | # CRAN related stuff 66 | cran-comments.md 67 | CRAN-SUBMISSION 68 | 69 | .Rprofile 70 | -------------------------------------------------------------------------------- /man/iucn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_iucn.R 3 | \name{iucn} 4 | \alias{iucn} 5 | \alias{get_iucn} 6 | \title{IUCN Red List of Threatened Species} 7 | \source{ 8 | \url{https://www.iucnredlist.org/resources/other-spatial-downloads} 9 | } 10 | \usage{ 11 | get_iucn(paths = NULL) 12 | } 13 | \arguments{ 14 | \item{paths}{A character vector to the respective species range files in GTiff 15 | format. Note, that theses files have to be downloaded manually.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This resource is part of the spatial data set Red List of Threatened Species 22 | released by IUCN. It is free to use under a non-commercial licence. For 23 | commercial uses, a request has to be sent to Integrated Biodiversity 24 | Assessment Tool (IBAT). 25 | } 26 | \details{ 27 | To use this data in mapme workflows, you will have to manually download the 28 | global data set and point towards the file path on your local machine. 29 | Please find the available data under the source link given below. 30 | } 31 | \references{ 32 | IUCN (2024). The IUCN Red List of Threatened Species. 33 | \url{https://www.iucnredlist.org} 34 | } 35 | \keyword{resource} 36 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_elevation.R: -------------------------------------------------------------------------------- 1 | test_that("srtm elevation works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | nasa_srtm <- list.files(system.file("res", "nasa_srtm", 8 | package = "mapme.biodiversity" 9 | ), pattern = ".tif$", full.names = TRUE) 10 | nasa_srtm <- rast(nasa_srtm) 11 | ce <- calc_elevation() 12 | result <- ce(x, nasa_srtm) 13 | ce <- calc_elevation(stats = c("mean", "median", "sd")) 14 | result_multi_stat <- ce(x, nasa_srtm) 15 | ce <- calc_elevation(engine = "zonal") 16 | result_zonal <- ce(x, nasa_srtm) 17 | ce <- calc_elevation(engine = "extract") 18 | result_extract <- ce(x, nasa_srtm) 19 | ce <- calc_elevation(engine = "exactextract") 20 | result_exact <- ce(x, nasa_srtm) 21 | 22 | expect_silent(.check_single_asset(result)) 23 | expect_equal( 24 | unique(result_multi_stat$variable), 25 | c("elevation_mean", "elevation_median", "elevation_sd") 26 | ) 27 | expect_equal( 28 | names(result_zonal), 29 | names(result_extract) 30 | ) 31 | expect_equal( 32 | names(result_zonal), 33 | names(result_exact) 34 | ) 35 | expect_equal( 36 | result_zonal$value, 37 | result_extract$value 38 | ) 39 | expect_snapshot( 40 | result_exact$value 41 | ) 42 | }) 43 | -------------------------------------------------------------------------------- /man/gmw.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gmw.R 3 | \docType{data} 4 | \name{gmw} 5 | \alias{gmw} 6 | \alias{get_gmw} 7 | \title{Global Mangrove Extent Polygon} 8 | \source{ 9 | \url{https://habitats.oceanplus.org/} 10 | } 11 | \usage{ 12 | get_gmw(years = c(1996, 2007:2010, 2015:2020)) 13 | } 14 | \arguments{ 15 | \item{years}{A numeric vector of the years for which to make GMW available.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This resource is part of the publication by Bunting et al. (2018) 22 | "The Global Mangrove Watch—A New 2010 Global Baseline of Mangrove Extent". 23 | The polygons represent the mangrove, which is tropical coastal vegetation 24 | and considered the most significant part of the marine ecosystem. This 25 | resource is available for the selected years in the period 1996- 2020 from 26 | Global Mangrove Watch (GMW), providing geospatial information about global 27 | mangrove extent. 28 | } 29 | \references{ 30 | Bunting P., Rosenqvist A., Lucas R., Rebelo L-M., Hilarides L., 31 | Thomas N., Hardy A., Itoh T., Shimada M. and Finlayson C.M. (2018). The Global 32 | Mangrove Watch – a New 2010 Global Baseline of Mangrove Extent. Remote Sensing 33 | 10(10): 1669. doi:10.3390/rs10101669. 34 | } 35 | \keyword{resource} 36 | -------------------------------------------------------------------------------- /tests/testthat/test-utils.R: -------------------------------------------------------------------------------- 1 | test_that("make_global_grid works", { 2 | standard_grid <- make_global_grid() 3 | nrows <- nrow(standard_grid) 4 | bbox <- st_bbox(standard_grid) 5 | points <- st_multipoint(matrix(c(-180, -50, -180, 80, 170, 80, 170, -50), ncol = 2, byrow = TRUE)) 6 | bbox_c <- st_bbox(points) 7 | st_crs(bbox_c) <- st_crs("EPSG:4326") 8 | expect_equal(nrows, 455) 9 | expect_equal(bbox, bbox_c) 10 | }) 11 | 12 | test_that(".check_available_years works", { 13 | expect_equal( 14 | check_available_years(2000:2020, 2000:2020, indicator = "treecover_area"), 15 | 2000:2020 16 | ) 17 | expect_equal( 18 | check_available_years(2000:2010, 2000:2020, indicator = "treecover_area"), 19 | 2000:2010 20 | ) 21 | expect_error( 22 | check_available_years(2000:2010, 2011:2020, indicator = "treecover_area"), 23 | "The target years do not intersect with the availability of treecover." 24 | ) 25 | expect_message( 26 | out <- check_available_years(2000:2011, 2011:2020, indicator = "treecover_area"), 27 | "Some target years are not available for treecover." 28 | ) 29 | expect_equal(out, 2011) 30 | }) 31 | 32 | test_that(".check_namespace works", { 33 | expect_error(check_namespace("not-a-package")) 34 | expect_message(check_namespace("not-a-package", error = FALSE)) 35 | expect_silent(check_namespace("base")) 36 | }) 37 | -------------------------------------------------------------------------------- /man/biodiversity_intactness_index_resource.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_biodiversity_intactness_index.R 3 | \name{biodiversity_intactness_index_resource} 4 | \alias{biodiversity_intactness_index_resource} 5 | \alias{get_biodiversity_intactness_index} 6 | \title{Biodiversity Intactness Index} 7 | \usage{ 8 | get_biodiversity_intactness_index(path = NULL) 9 | } 10 | \arguments{ 11 | \item{path}{A character vector to the biodiversity intactness index ASCII file.} 12 | } 13 | \value{ 14 | A function that returns an \code{sf} footprints object. 15 | } 16 | \description{ 17 | The variable is the modelled average abundance of originally-present species, 18 | relative to their abundance in an intact ecosystem. Please refer to 19 | Newbold et al. (2016) for all details, and please cite it when using these 20 | data. 21 | } 22 | \details{ 23 | To use this data in mapme workflows, you will have to manually download the 24 | global data set and point towards the file path on your local machine. 25 | Please find the available data under the source link given below. 26 | } 27 | \references{ 28 | Tim Newbold; Lawrence Hudson; Andy Arnell; Sara Contu et al. 29 | (2016). Global map of the Biodiversity Intactness Index, from Newbold et al. 30 | (2016) Science [Data set]. Natural History Museum. 31 | \doi{doi:10.5519/0009936} 32 | } 33 | \keyword{resource} 34 | -------------------------------------------------------------------------------- /data-raw/carbon.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(terra) 3 | library(sf) 4 | 5 | x <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 6 | package = "mapme.biodiversity" 7 | ) %>% 8 | read_sf() 9 | 10 | outdir <- tempfile() 11 | dir.create(outdir) 12 | mapme_options(outdir = outdir) 13 | 14 | options(timeout = 600) 15 | get_resources(x, get_irr_carbon(), get_vul_carbon(), get_man_carbon()) 16 | resources <- prep_resources(x) 17 | tindex <- mapme.biodiversity:::.avail_resources() 18 | 19 | outdir <- "inst/resources/irr_carbon" 20 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 21 | writeRaster(resources$irr_carbon, 22 | file.path(outdir, tindex$irr_carbon$filename), 23 | datatype = "INT2U", overwrite = TRUE, 24 | wopt = list(gdal = c("COMPRESS=LZW")) 25 | ) 26 | 27 | outdir <- "inst/resources/vul_carbon" 28 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 29 | writeRaster(resources$vul_carbon, 30 | file.path(outdir, tindex$vul_carbon$filename), 31 | datatype = "INT2U", overwrite = TRUE, 32 | wopt = list(gdal = c("COMPRESS=LZW")) 33 | ) 34 | 35 | outdir <- "inst/resources/man_carbon" 36 | dir.create(outdir, recursive = TRUE, showWarnings = FALSE) 37 | writeRaster(resources$man_carbon, 38 | file.path(outdir, tindex$man_carbon$filename), 39 | datatype = "INT2U", overwrite = TRUE, 40 | wopt = list(gdal = c("COMPRESS=LZW")) 41 | ) 42 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_tri.R: -------------------------------------------------------------------------------- 1 | test_that("terrain ruggedness index works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | nasa_srtm <- list.files(system.file("res", "nasa_srtm", 8 | package = "mapme.biodiversity" 9 | ), pattern = ".tif$", full.names = TRUE) 10 | nasa_srtm <- rast(nasa_srtm) 11 | 12 | ctri <- calc_tri() 13 | expect_true(is.null(ctri(x, NULL))) 14 | result <- ctri(x, nasa_srtm) 15 | ctri <- calc_tri(stats = c("mean", "median", "sd")) 16 | result_multi_stat <- ctri(x, nasa_srtm) 17 | ctri <- calc_tri(engine = "zonal") 18 | result_zonal <- ctri(x, nasa_srtm) 19 | ctri <- calc_tri(engine = "extract") 20 | result_extract <- ctri(x, nasa_srtm) 21 | ctri <- calc_tri(engine = "exactextract") 22 | result_exact <- ctri(x, nasa_srtm) 23 | 24 | expect_silent(.check_single_asset(result)) 25 | expect_silent(.check_single_asset(result_multi_stat)) 26 | expect_silent(.check_single_asset(result_zonal)) 27 | expect_silent(.check_single_asset(result_extract)) 28 | expect_silent(.check_single_asset(result_exact)) 29 | 30 | vars <- c("tri_mean", "tri_median", "tri_sd") 31 | expect_equal(unique(result_multi_stat$variable), vars) 32 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 33 | expect_snapshot(result_exact$value) 34 | }) 35 | -------------------------------------------------------------------------------- /data-raw/gfw_treecover.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(terra) 3 | library(mapme.biodiversity) 4 | 5 | tmp_loc <- tempfile() 6 | dir.create(tmp_loc) 7 | mapme_options(outdir = tmp_loc) 8 | 9 | x <- system.file("extdata", "gfw_sample.gpkg", 10 | package = "mapme.biodiversity" 11 | ) 12 | x <- st_read(x) 13 | 14 | get_resources( 15 | x, 16 | get_gfw_treecover(version = "GFC-2023-v1.11"), 17 | get_gfw_lossyear(version = "GFC-2023-v1.11"), 18 | get_gfw_emissions() 19 | ) 20 | 21 | rs <- prep_resources(x) 22 | 23 | unlink("inst/res/gfw_treecover", force = T, recursive = TRUE) 24 | dir.create("inst/res/gfw_treecover/") 25 | writeRaster(rs$gfw_treecover, 26 | filename = "inst/res/gfw_treecover/Hansen_GFC-2023-v1.11_treecover2000_20N_080W.tif", 27 | gdal = "COMPRESS=LZW", datatype = "INT1U" 28 | ) 29 | 30 | 31 | unlink("inst/res/gfw_lossyear", force = T, recursive = TRUE) 32 | dir.create("inst/res/gfw_lossyear/") 33 | writeRaster(rs$gfw_lossyear, 34 | filename = "inst/res/gfw_lossyear/Hansen_GFC-2023-v1.11_lossyear_20N_080W.tif", 35 | gdal = "COMPRESS=LZW", datatype = "INT1U" 36 | ) 37 | 38 | unlink("inst/res/gfw_emissions", force = T, recursive = TRUE) 39 | dir.create("inst/res/gfw_emissions/") 40 | writeRaster(rs$gfw_emissions, 41 | filename = "inst/res/gfw_emissions/gfw_forest_carbon_gross_emissions_Mg_CO2e_px_20N_080W.tif", 42 | gdal = c("COMPRESS=DEFLATE", "PREDICTOR=2"), datatype = "FLT4S" 43 | ) 44 | -------------------------------------------------------------------------------- /man/ipbes_biome_stats.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_ipbes_biomes.R 3 | \name{ipbes_biome_stats} 4 | \alias{ipbes_biome_stats} 5 | \alias{calc_ipbes_biomes} 6 | \title{Calculate areal statistics for IBPES Biomes} 7 | \usage{ 8 | calc_ipbes_biomes() 9 | } 10 | \value{ 11 | A function that returns an indicator tibble with the biome class 12 | as variable and the respective area (in ha) as value. 13 | } 14 | \description{ 15 | This indicator calculates the areal distribution of different biome classes 16 | within an asset based on the IBPES biomes dataset. 17 | } 18 | \details{ 19 | The required resources for this indicator are: 20 | \itemize{ 21 | \item \link{ipbes_biomes} 22 | } 23 | } 24 | \examples{ 25 | \dontshow{ 26 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 27 | } 28 | \dontrun{ 29 | library(sf) 30 | library(mapme.biodiversity) 31 | 32 | outdir <- file.path(tempdir(), "mapme-data") 33 | dir.create(outdir, showWarnings = FALSE) 34 | 35 | mapme_options( 36 | outdir = outdir, 37 | verbose = FALSE 38 | ) 39 | 40 | aoi <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 41 | package = "mapme.biodiversity" 42 | ) \%>\% 43 | read_sf() \%>\% 44 | get_resources(get_ipbes_biomes()) \%>\% 45 | calc_indicators(calc_ipbes_biomes()) \%>\% 46 | portfolio_long() 47 | 48 | aoi 49 | } 50 | } 51 | \keyword{indicator} 52 | -------------------------------------------------------------------------------- /man/biome.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_biome.R 3 | \name{biome} 4 | \alias{biome} 5 | \alias{calc_biome} 6 | \title{Calculate biomes statistics (TEOW) based on WWF} 7 | \usage{ 8 | calc_biome() 9 | } 10 | \value{ 11 | A function that returns an indicator tibble with variable biome type 12 | and corresponding area (in ha) as values. 13 | } 14 | \description{ 15 | This function allows to efficiently retrieve the name of the biomes 16 | and compute the corresponding area from Terrestrial Ecoregions of the 17 | World (TEOW) - World Wildlife Fund (WWF) for polygons. For each polygon, 18 | the name and area of the biomes (in hectare) is returned. 19 | The required resources for this indicator are: 20 | \itemize{ 21 | \item \link{teow} 22 | } 23 | } 24 | \examples{ 25 | \dontshow{ 26 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 27 | } 28 | \dontrun{ 29 | library(sf) 30 | library(mapme.biodiversity) 31 | 32 | outdir <- file.path(tempdir(), "mapme-data") 33 | dir.create(outdir, showWarnings = FALSE) 34 | 35 | mapme_options( 36 | outdir = outdir, 37 | verbose = FALSE 38 | ) 39 | 40 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 41 | package = "mapme.biodiversity" 42 | ) \%>\% 43 | read_sf() \%>\% 44 | get_resources(get_teow()) \%>\% 45 | calc_indicators(calc_biome()) \%>\% 46 | portfolio_long() 47 | 48 | aoi 49 | } 50 | } 51 | \keyword{indicator} 52 | -------------------------------------------------------------------------------- /man/worldclim_precipitation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_worldclim.R 3 | \name{worldclim_precipitation} 4 | \alias{worldclim_precipitation} 5 | \alias{get_worldclim_precipitation} 6 | \title{Downloads WorldClim Mean Precipitation layer} 7 | \source{ 8 | \url{https://www.worldclim.org/data/index.html} 9 | } 10 | \usage{ 11 | get_worldclim_precipitation( 12 | years = 1960:2024, 13 | resolution = c("2.5m", "5m", "10m") 14 | ) 15 | } 16 | \arguments{ 17 | \item{years}{A numeric vector indicating for which years to make the 18 | resource available.} 19 | 20 | \item{resolution}{A character vector indicating the desired resolution.} 21 | } 22 | \value{ 23 | A function that returns an \code{sf} footprint object. 24 | } 25 | \description{ 26 | This resource is published by Fick et al. (2017) "WorldClim 2: new 1-km 27 | spatial resolution climate surfaces for global land areas" and 28 | represents multiple climatic variables from which we will be requiring minimum 29 | temperature, maximum temperature, and mean precipitation layers. The layers are 30 | available to download for the period 1960 - 2024 on monthly basis from WorldClim. 31 | } 32 | \details{ 33 | This resource represents the average precipitation, layers available to 34 | download for the period 1960 - 2024 on monthly basis from WorldClim. Encoded 35 | as (mm), representing the mean precipitation per output grid cell. 36 | } 37 | \keyword{resource} 38 | -------------------------------------------------------------------------------- /man/deforestation_drivers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_deforestation_drivers.R 3 | \name{deforestation_drivers} 4 | \alias{deforestation_drivers} 5 | \alias{calc_deforestation_drivers} 6 | \title{Calculate deforestation drivers} 7 | \usage{ 8 | calc_deforestation_drivers() 9 | } 10 | \value{ 11 | A function that returns an indicator tibble with deforestation 12 | drivers as variable and corresponding area (in ha) as value. 13 | } 14 | \description{ 15 | This function extracts areal statistics for the drivers of deforestation 16 | based on the data source produced by Fritz et al (2022). 17 | } 18 | \details{ 19 | The required resource for this indicator is: 20 | \itemize{ 21 | \item \link{fritz_et_al} 22 | } 23 | } 24 | \examples{ 25 | \dontshow{ 26 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 27 | } 28 | \dontrun{ 29 | library(sf) 30 | library(mapme.biodiversity) 31 | 32 | outdir <- file.path(tempdir(), "mapme-data") 33 | dir.create(outdir, showWarnings = FALSE) 34 | 35 | mapme_options( 36 | outdir = outdir, 37 | verbose = FALSE 38 | ) 39 | 40 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 41 | package = "mapme.biodiversity" 42 | ) \%>\% 43 | read_sf() \%>\% 44 | get_resources(get_fritz_et_al(resolution = 100)) \%>\% 45 | calc_indicators(calc_deforestation_drivers()) \%>\% 46 | portfolio_long() 47 | 48 | aoi 49 | } 50 | } 51 | \keyword{indicator} 52 | -------------------------------------------------------------------------------- /man/ucdp_ged.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_ucdp_ged.R 3 | \name{ucdp_ged} 4 | \alias{ucdp_ged} 5 | \alias{get_ucdp_ged} 6 | \title{UCDP Georeferenced Event Dataset (UCDP GED)} 7 | \source{ 8 | \url{https://ucdp.uu.se/downloads/} 9 | } 10 | \usage{ 11 | get_ucdp_ged(version = "latest") 12 | } 13 | \arguments{ 14 | \item{version}{A character vector specifying 15 | the version to download. Defaults to "latest".} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This resource distributed by the Uppsala Conflict Data Program (UCDP) constitutes 22 | its most disaggregated dataset on individual events of organized violence. 23 | It encodes the different actors involved, is spatially disaggregated down 24 | to village levels anc currently covers the time period of 1989 to 2021. 25 | Older versions of the data set can be downloaded, but users are recommended 26 | to download the latest data set. 27 | } 28 | \details{ 29 | The following versions are available: 30 | \itemize{ 31 | \item 5.0 32 | \item 17.1 33 | \item 17.2 34 | \item 18.1 35 | \item 19.1 36 | \item 20.1 37 | \item 21.1 38 | \item 22.1 39 | \item 23.1 40 | \item 24.1 41 | \item latest 42 | } 43 | } 44 | \references{ 45 | Davies, Shawn, Therese Pettersson & Magnus Öberg (2022). 46 | Organized violence 1989-2021 and drone warfare. 47 | Journal of Peace Research 59(4). 48 | \doi{10.1177/00223433221108428} 49 | } 50 | \keyword{resource} 51 | -------------------------------------------------------------------------------- /man/ecoregion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_ecoregion.R 3 | \name{ecoregion} 4 | \alias{ecoregion} 5 | \alias{calc_ecoregion} 6 | \title{Calculate terrestrial ecoregions statistics (TEOW) based on WWF} 7 | \usage{ 8 | calc_ecoregion() 9 | } 10 | \value{ 11 | A function that returns an indicator tibble with ecoregion type as 12 | variable and corresponding area (in ha) as value. 13 | } 14 | \description{ 15 | This function allows to efficiently retrieve the name of the ecoregions 16 | and compute the corresponding area from Terrestrial Ecoregions of the 17 | World (TEOW) - World Wildlife Fund (WWF) for polygons. For each polygon, 18 | the name and area of the ecoregions (in hectare) is returned. 19 | The required resources for this indicator are: 20 | \itemize{ 21 | \item \link{teow} 22 | } 23 | } 24 | \examples{ 25 | \dontshow{ 26 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 27 | } 28 | \dontrun{ 29 | library(sf) 30 | library(mapme.biodiversity) 31 | 32 | outdir <- file.path(tempdir(), "mapme-data") 33 | dir.create(outdir, showWarnings = FALSE) 34 | 35 | mapme_options( 36 | outdir = outdir, 37 | verbose = FALSE 38 | ) 39 | 40 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 41 | package = "mapme.biodiversity" 42 | ) \%>\% 43 | read_sf() \%>\% 44 | get_resources(get_teow()) \%>\% 45 | calc_indicators(calc_ecoregion()) \%>\% 46 | portfolio_long() 47 | 48 | aoi 49 | } 50 | } 51 | \keyword{indicator} 52 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_population_count.R: -------------------------------------------------------------------------------- 1 | test_that(".calc_population_count works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_worldpop(years = 2010:2020)) 12 | worldpop <- prep_resources(x)[["worldpop"]] 13 | 14 | cpc <- calc_population_count() 15 | result <- cpc(x, worldpop) 16 | cpc <- calc_population_count(stats = c("mean", "median", "sd")) 17 | result_multi_stat <- cpc(x, worldpop) 18 | cpc <- calc_population_count(engine = "zonal") 19 | result_zonal <- cpc(x, worldpop) 20 | cpc <- calc_population_count(engine = "extract") 21 | result_extract <- cpc(x, worldpop) 22 | cpc <- calc_population_count(engine = "exactextract") 23 | result_exact <- cpc(x, worldpop) 24 | 25 | expect_silent(.check_single_asset(result)) 26 | expect_silent(.check_single_asset(result_multi_stat)) 27 | expect_silent(.check_single_asset(result_zonal)) 28 | expect_silent(.check_single_asset(result_extract)) 29 | expect_silent(.check_single_asset(result_exact)) 30 | 31 | vars <- c("population_mean", "population_median", "population_sd") 32 | expect_equal(unique(result_multi_stat$variable), vars) 33 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 34 | expect_snapshot(result_exact$value) 35 | }) 36 | -------------------------------------------------------------------------------- /man/worldclim_max_temperature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_worldclim.R 3 | \name{worldclim_max_temperature} 4 | \alias{worldclim_max_temperature} 5 | \alias{get_worldclim_max_temperature} 6 | \title{Downloads WorldClim Maximum Temperature layer} 7 | \source{ 8 | \url{https://www.worldclim.org/data/index.html} 9 | } 10 | \usage{ 11 | get_worldclim_max_temperature( 12 | years = 2000:2024, 13 | resolution = c("2.5m", "5m", "10m") 14 | ) 15 | } 16 | \arguments{ 17 | \item{years}{A numeric vector indicating for which years to make the 18 | resource available. Defaults to 2000:2024.} 19 | 20 | \item{resolution}{A character vector indicating the desired resolution: 21 | "2.5m", "5m", or "10m".} 22 | } 23 | \value{ 24 | A function that returns an \code{sf} footprint object. 25 | } 26 | \description{ 27 | This resource is published by Fick et al. (2017) "WorldClim 2: new 1-km 28 | spatial resolution climate surfaces for global land areas" and 29 | represents multiple climatic variables from which we will be requiring minimum 30 | temperature, maximum temperature, and mean precipitation layers. The layers are 31 | available to download for the period 1960 - 2024 on monthly basis from WorldClim. 32 | } 33 | \details{ 34 | This resource represents the maximum temperature, layers available to 35 | download for the period 1960 - 2024 on monthly basis from WorldClim. Encoded 36 | as (°C), representing the maximum temperature per output grid cell. 37 | } 38 | \keyword{resource} 39 | -------------------------------------------------------------------------------- /man/worldclim_min_temperature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_worldclim.R 3 | \name{worldclim_min_temperature} 4 | \alias{worldclim_min_temperature} 5 | \alias{get_worldclim_min_temperature} 6 | \title{Downloads WorldClim Minimum Temperature layer} 7 | \source{ 8 | \url{https://www.worldclim.org/data/index.html} 9 | } 10 | \usage{ 11 | get_worldclim_min_temperature( 12 | years = 2000:2024, 13 | resolution = c("2.5m", "5m", "10m") 14 | ) 15 | } 16 | \arguments{ 17 | \item{years}{A numeric vector indicating for which years to make the 18 | resource available. Defaults to 2000:2024.} 19 | 20 | \item{resolution}{A character vector indicating the desired resolution: 21 | "2.5m", "5m", or "10m".} 22 | } 23 | \value{ 24 | A function that returns an \code{sf} footprint object. 25 | } 26 | \description{ 27 | This resource is published by Fick et al. (2017) "WorldClim 2: new 1-km 28 | spatial resolution climate surfaces for global land areas" and 29 | represents multiple climatic variables from which we will be requiring minimum 30 | temperature, maximum temperature, and mean precipitation layers. The layers are 31 | available to download for the period 1960 - 2024 on monthly basis from WorldClim. 32 | } 33 | \details{ 34 | This resource represents the minimum temperature, layers available to 35 | download for the period 1960 - 2024 on monthly basis from WorldClim. Encoded 36 | as (°C), representing the minimum temperature per output grid cell. 37 | } 38 | \keyword{resource} 39 | -------------------------------------------------------------------------------- /man/esalandcover.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_esalandcover.R 3 | \name{esalandcover} 4 | \alias{esalandcover} 5 | \alias{get_esalandcover} 6 | \title{ESA Copernicus Global Land Cover layer} 7 | \source{ 8 | \url{https://zenodo.org/records/3939050} 9 | } 10 | \usage{ 11 | get_esalandcover(years = 2015L:2019L) 12 | } 13 | \arguments{ 14 | \item{years}{A numeric vector indicating the years for which to make the 15 | resource available.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This 100 meter spatial resolution land cover resource is published by Buchhorn 22 | et al. (2020) "Copernicus Global Land Cover Layers—Collection 2". The resource 23 | represents the actual surface cover of ground available annually for the period 24 | 2015 to 2019. The cell values range from 0 to 200, representing total of 23 25 | discrete classifications from ESA. 26 | } 27 | \details{ 28 | This function mimics the behavior of the original \code{get_esalandcover()} function by 29 | downloading the parts of the global raster that correspond to the 20° x 20° tiles used 30 | previously. The files are named the same as before. This allows other code that uses 31 | this resource to remain unchanged. 32 | } 33 | \references{ 34 | Buchhorn, M., Lesiv, M., Tsendbazar, N.-E., Herold, M., Bertels, L., 35 | & Smets, B. (2020). Copernicus Global Land Cover Layers - Collection 2. 36 | Remote Sensing, 12(6), 1044. 37 | \doi{doi:10.3390/rs12061044} 38 | } 39 | \keyword{resource} 40 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_soilproperties.R: -------------------------------------------------------------------------------- 1 | test_that("soilpoperties works", { 2 | skip_on_cran() 3 | skip_if_not(Sys.getenv("USER") == "darius") 4 | 5 | x <- read_sf( 6 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 7 | package = "mapme.biodiversity" 8 | ) 9 | ) 10 | 11 | mapme_options(outdir = NULL, verbose = FALSE) 12 | suppressWarnings(get_resources(x, get_soilgrids( 13 | layer = "clay", 14 | depth = "0-5cm", 15 | stat = "mean" 16 | ))) 17 | soilgrids <- prep_resources(x)[["soilgrids"]] 18 | x <- st_transform(x, st_crs(soilgrids)) 19 | 20 | csp <- calc_soilproperties() 21 | expect_true(is.null(csp(x, NULL))) 22 | 23 | csp <- calc_soilproperties() 24 | result <- csp(x, soilgrids) 25 | csp <- calc_soilproperties(engine = "extract", stats = c("mean", "median", "sd")) 26 | result_multi_stat <- csp(x, soilgrids) 27 | csp <- calc_soilproperties(engine = "zonal") 28 | result_zonal <- csp(x, soilgrids) 29 | csp <- calc_soilproperties(engine = "extract") 30 | result_extract <- csp(x, soilgrids) 31 | csp <- calc_soilproperties(engine = "exactextract") 32 | result_exact <- csp(x, soilgrids) 33 | 34 | expect_silent(.check_single_asset(result)) 35 | expect_silent(.check_single_asset(result_multi_stat)) 36 | expect_silent(.check_single_asset(result_zonal)) 37 | expect_silent(.check_single_asset(result_extract)) 38 | expect_silent(.check_single_asset(result_exact)) 39 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 40 | expect_snapshot(result_exact$value) 41 | }) 42 | -------------------------------------------------------------------------------- /man/mangroves_area.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_mangroves_area.R 3 | \docType{data} 4 | \name{mangroves_area} 5 | \alias{mangroves_area} 6 | \alias{calc_mangroves_area} 7 | \title{Calculate mangrove extent based on Global Mangrove Watch (GMW)} 8 | \usage{ 9 | calc_mangroves_area() 10 | } 11 | \value{ 12 | A function that returns an indicator tibble with mangroves as variable 13 | and corresponding areas (in ha) as value. 14 | } 15 | \description{ 16 | This function allows to efficiently calculate area of mangrove from 17 | Global Mangrove Watch - World Conservation Monitoring Centre (WCMC) 18 | for polygons. For each polygon, the area of the mangrove (in hectare) 19 | for desired year is returned. 20 | } 21 | \details{ 22 | The required resources for this indicator are: 23 | \itemize{ 24 | \item \link{gmw} 25 | } 26 | } 27 | \examples{ 28 | \dontshow{ 29 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 30 | } 31 | \dontrun{ 32 | library(sf) 33 | library(mapme.biodiversity) 34 | 35 | outdir <- file.path(tempdir(), "mapme-data") 36 | dir.create(outdir, showWarnings = FALSE) 37 | 38 | mapme_options( 39 | outdir = outdir, 40 | verbose = FALSE 41 | ) 42 | 43 | aoi <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 44 | package = "mapme.biodiversity" 45 | ) \%>\% 46 | read_sf() \%>\% 47 | get_resources(get_gmw(years = c(1996, 2016))) \%>\% 48 | calc_indicators(calc_mangroves_area()) \%>\% 49 | portfolio_long() 50 | 51 | aoi 52 | } 53 | } 54 | \keyword{indicator} 55 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_precipitation_chelsa.R: -------------------------------------------------------------------------------- 1 | test_that("precipitation indicator works", { 2 | x <- read_sf( 3 | system.file("extdata", "gfw_sample.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_chelsa(years = 2010)) 12 | chelsa <- prep_resources(x)[["chelsa"]] 13 | 14 | expect_message(cpc <- calc_precipitation_chelsa(1978:1982)) 15 | expect_error(calc_precipitation_chelsa(years = 1970:1971)) 16 | expect_error(calc_precipitation_chelsa(years = 1981:1982, engine = "not-av")) 17 | expect_true(is.null(cpc(x, NULL))) 18 | cpc <- calc_precipitation_chelsa(years = 2010) 19 | result <- cpc(x, chelsa) 20 | cpc <- calc_precipitation_chelsa(years = 2010, engine = "zonal") 21 | result_zonal <- cpc(x, chelsa) 22 | cpc <- calc_precipitation_chelsa(years = 2010, engine = "extract") 23 | result_extract <- cpc(x, chelsa) 24 | cpc <- calc_precipitation_chelsa(years = 2010, engine = "exactextract") 25 | result_exact <- cpc(x, chelsa) 26 | 27 | expect_silent(.check_single_asset(result)) 28 | expect_silent(.check_single_asset(result_zonal)) 29 | expect_silent(.check_single_asset(result_extract)) 30 | expect_silent(.check_single_asset(result_exact)) 31 | 32 | expect_equal(unique(result$variable), "precipitation") 33 | expect_equal(result_zonal$value, result_extract$value, 34 | tolerance = 1e-4 35 | ) 36 | expect_snapshot(result$value) 37 | }) 38 | -------------------------------------------------------------------------------- /man/chirps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_chirps.R 3 | \name{chirps} 4 | \alias{chirps} 5 | \alias{get_chirps} 6 | \title{Climate Hazards Group InfraRed Precipitation with Station data (CHIRPS)} 7 | \source{ 8 | \url{https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/cogs/} 9 | } 10 | \usage{ 11 | get_chirps(years = 1981:2020) 12 | } 13 | \arguments{ 14 | \item{years}{A numeric vector of the years to download CHIRPS precipitation 15 | layers. Must be greater 1981, defaults to \code{c(1981:2020)}.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This resource is published by Funk et al. (2015) and represents a quasi-global 22 | (50°S-50°S) rainfall estimation at a monthly resolution starting with the year 23 | 1981 to the near-present. It has a spatial resolution of 0.05°. The data can 24 | be used to retrieve information on the amount of rainfall. Due to the availability 25 | of +30 years, anomaly detection and long-term average analysis is also possible. 26 | The routine will download the complete archive in order to support long-term 27 | average and anomaly calculations with respect to the 1981 - 2010 climate normal 28 | period. Thus no additional arguments need to be specified. 29 | } 30 | \references{ 31 | Funk, C., Peterson, P., Landsfeld, M. et al. The climate hazards 32 | infrared precipitation with stations—a new environmental record for 33 | monitoring extremes. Sci Data 2, 150066 (2015). 34 | \doi{10.1038/sdata.2015.66} 35 | } 36 | \keyword{resource} 37 | -------------------------------------------------------------------------------- /data-raw/worldclim.R: -------------------------------------------------------------------------------- 1 | library(mapme.biodiversity) 2 | library(future) 3 | library(terra) 4 | library(sf) 5 | 6 | tmp_loc <- tempfile() 7 | dir.create(tmp_loc) 8 | mapme_options(outdir = tmp_loc) 9 | 10 | x <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 11 | package = "mapme.biodiversity" 12 | ) %>% st_read() 13 | 14 | plan(multisession, workers = 6) 15 | get_resources( 16 | x, get_worldclim_max_temperature(years = 2018, resolution = "2.5m"), 17 | get_worldclim_min_temperature(years = 2018, resolution = "2.5m"), 18 | get_worldclim_precipitation(years = 2018, resolution = "2.5m") 19 | ) 20 | plan(sequential) 21 | 22 | resources <- prep_resources(x) 23 | 24 | wctmax <- mask(resources$worldclim_max_temperature, x) 25 | outdir <- "inst/res/worldclim_max_temperature/" 26 | dir.create(outdir, showWarnings = FALSE) 27 | writeRaster(wctmax, file.path(outdir, paste0(names(wctmax), ".tif")), 28 | overwrite = TRUE, 29 | gdal = c("COMPRESS=LZW", "PREDICTOR=2") 30 | ) 31 | 32 | wctmin <- mask(resources$worldclim_min_temperature, x) 33 | outdir <- "inst/res/worldclim_min_temperature/" 34 | dir.create(outdir, showWarnings = FALSE) 35 | writeRaster(wctmin, file.path(outdir, paste0(names(wctmin), ".tif")), 36 | overwrite = TRUE, 37 | gdal = c("COMPRESS=LZW", "PREDICTOR=2") 38 | ) 39 | 40 | wcprec <- mask(resources$worldclim_precipitation, x) 41 | outdir <- "inst/res/worldclim_precipitation/" 42 | dir.create(outdir, showWarnings = FALSE) 43 | writeRaster(wcprec, file.path(outdir, paste0(names(wcprec), ".tif")), 44 | overwrite = TRUE, 45 | gdal = c("COMPRESS=LZW", "PREDICTOR=2") 46 | ) 47 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_traveltime.R: -------------------------------------------------------------------------------- 1 | test_that("traveltime works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_nelson_et_al(ranges = "100k_200k")) 12 | nelson_et_al <- prep_resources(x)[["nelson_et_al"]] 13 | 14 | ctt <- calc_traveltime() 15 | expect_true(is.null(ctt(x, NULL))) 16 | result <- ctt(x, nelson_et_al) 17 | ctt <- calc_traveltime(stats = c("mean", "median", "sd")) 18 | result_multi_stat <- ctt(x, nelson_et_al) 19 | ctt <- calc_traveltime(engine = "zonal") 20 | result_zonal <- ctt(x, nelson_et_al) 21 | ctt <- calc_traveltime(engine = "extract") 22 | result_extract <- ctt(x, nelson_et_al) 23 | ctt <- calc_traveltime(engine = "exactextract") 24 | result_exact <- ctt(x, nelson_et_al) 25 | 26 | expect_silent(.check_single_asset(result)) 27 | expect_silent(.check_single_asset(result_multi_stat)) 28 | expect_silent(.check_single_asset(result_zonal)) 29 | expect_silent(.check_single_asset(result_extract)) 30 | expect_silent(.check_single_asset(result_exact)) 31 | 32 | vars <- c( 33 | "100k_200k_traveltime_mean", "100k_200k_traveltime_median", 34 | "100k_200k_traveltime_sd" 35 | ) 36 | expect_equal(unique(result_multi_stat$variable)[1:3], vars) 37 | expect_equal(result_zonal$value, result_zonal$value, tolerance = 1e-4) 38 | expect_snapshot(result_exact$value) 39 | }) 40 | -------------------------------------------------------------------------------- /inst/res/biodiversity_intactness_index/lbii.asc: -------------------------------------------------------------------------------- 1 | ncols 17 2 | nrows 8 3 | xllcorner -59.850000000000 4 | yllcorner 8.300000000000 5 | cellsize 0.008333333333 6 | NODATA_value nan 7 | 0.9192911982536315918 0.84738969802856445312 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 8 | 0.96659547090530395508 0.94478428363800048828 0.9379494786262512207 0.91145950555801391602 nan nan nan nan nan nan nan nan nan nan nan nan nan 9 | nan nan nan 0.92522782087326049805 0.94427400827407836914 0.95934718847274780273 nan nan nan nan 0.83497571945190429688 0.86222422122955322266 0.94979012012481689453 nan nan nan nan 10 | nan nan nan nan 0.92205458879470825195 0.92618638277053833008 0.95295119285583496094 0.91682922840118408203 0.90592360496520996094 0.88729369640350341797 0.92310488224029541016 0.85501950979232788086 0.86508828401565551758 0.86244678497314453125 0.94820958375930786133 nan nan 11 | nan nan nan nan nan nan nan 0.9398238062858581543 0.96103847026824951172 0.95053428411483764648 0.87660002708435058594 0.91594922542572021484 0.95138901472091674805 0.95949351787567138672 0.86129438877105712891 0.94590651988983154297 nan 12 | nan nan nan nan nan nan nan nan nan nan 0.95304471254348754883 0.93774437904357910156 0.92031711339950561523 0.90744358301162719727 0.96678429841995239258 0.93842202425003051758 0.86613672971725463867 13 | nan nan nan nan nan nan nan nan nan nan nan nan 0.90449100732803344727 0.90626692771911621094 0.9422104954719543457 0.96764677762985229492 0.94515711069107055664 14 | nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 0.96467298269271850586 nan 15 | -------------------------------------------------------------------------------- /man/spds_exists.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/spatial-utils.R 3 | \name{spds_exists} 4 | \alias{spds_exists} 5 | \title{Check if a spatial data sets exists} 6 | \usage{ 7 | spds_exists(path, oo = character(0), what = c("vector", "raster")) 8 | } 9 | \arguments{ 10 | \item{path}{A length 1 character vector with a GDAL readable file path.} 11 | 12 | \item{oo}{Either a list or a character vector with opening options (-oo) 13 | of the respective GDAL driver. A list must have equal length of the 14 | input sources, a vector will be recycled.} 15 | 16 | \item{what}{A character vector indicating if the resource is a vector or raster file.} 17 | } 18 | \value{ 19 | A logical, TRUE if the file exists, FALSE if it does not. 20 | } 21 | \description{ 22 | This function uses a file path readable by GDAL to check if it can query 23 | it for information. Note, this should also work for remote files, e.g. 24 | in an S3 bucket. You can use this function in your custom resource 25 | function to query if a file is already present at the destination. 26 | Note, that performance will be dependent on your connection to the 27 | server. It can also be used for files on the local file system. 28 | } 29 | \examples{ 30 | 31 | # a vector resource 32 | vec <- system.file("shape/nc.shp", package = "sf") 33 | spds_exists(vec, what = "vector") 34 | 35 | # a raster resource 36 | ras <- system.file("ex/elev.tif", package = "terra") 37 | spds_exists(ras, what = "raster") 38 | 39 | # a non existing file 40 | spds_exists("not-here.gpkg", what = "vector") 41 | 42 | } 43 | \keyword{utils} 44 | -------------------------------------------------------------------------------- /man/global_surface_water_seasonality.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gsw.R 3 | \name{global_surface_water_seasonality} 4 | \alias{global_surface_water_seasonality} 5 | \alias{get_global_surface_water_seasonality} 6 | \title{Global Surface Water Seasonality} 7 | \source{ 8 | \url{https://global-surface-water.appspot.com/} 9 | } 10 | \usage{ 11 | get_global_surface_water_seasonality(version = "v1_4_2021") 12 | } 13 | \arguments{ 14 | \item{version}{A character vector indicating the version of the GSW data set 15 | to make available.} 16 | } 17 | \value{ 18 | A character of file paths. 19 | } 20 | \description{ 21 | The Global Surface Water dataset was developed by the European Commission's 22 | Joint Research Centre in the framework of the Copernicus Programme. It maps 23 | the location and temporal distribution of water surfaces at the global scale 24 | over the past 3.8 decades and provides statistics on their extent and change. 25 | It is provisioned as a global tiled raster resource available for all land 26 | areas. The reported data represent aggregated observations between 1984 - 2021. 27 | } 28 | \details{ 29 | GSW seasonality describes the intra-annual distribution of surface water for 30 | each pixel. The raster files have integer cell values between \code{[0, 12]}, 31 | indicating how many months per year the pixel was classified as water. 32 | } 33 | \references{ 34 | Pekel, JF., Cottam, A., Gorelick, N. et al. High-resolution 35 | mapping of global surface water and its long-term changes. Nature 540, 36 | 418–422 (2016). \doi{doi:10.1038/nature20584} 37 | } 38 | \keyword{resource} 39 | -------------------------------------------------------------------------------- /tests/testthat/test-get_worldclim.R: -------------------------------------------------------------------------------- 1 | test_that(".get_worldclim works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | 12 | gcv <- get_worldclim_min_temperature(years = 2018, resolution = "2.5m") 13 | files <- sprintf("wc2.1_cruts4.09_2.5m_tmin_2018-%02d.tif", 1:12) 14 | expect_equal(gcv(x)[["filename"]], files) 15 | 16 | gcv <- get_worldclim_max_temperature(years = 2018, resolution = "2.5m") 17 | files <- sprintf("wc2.1_cruts4.09_2.5m_tmax_2018-%02d.tif", 1:12) 18 | expect_equal(gcv(x)[["filename"]], files) 19 | 20 | gcv <- get_worldclim_precipitation(years = 2018, resolution = "2.5m") 21 | files <- sprintf("wc2.1_cruts4.09_2.5m_prec_2018-%02d.tif", 1:12) 22 | expect_equal(gcv(x)[["filename"]], files) 23 | 24 | gcv <- get_worldclim_min_temperature(years = 2018, resolution = "5m") 25 | files <- sprintf("wc2.1_cruts4.09_5m_tmin_2018-%02d.tif", 1:12) 26 | expect_equal(gcv(x)[["filename"]], files) 27 | 28 | gcv <- get_worldclim_max_temperature(years = 2018, resolution = "5m") 29 | files <- sprintf("wc2.1_cruts4.09_5m_tmax_2018-%02d.tif", 1:12) 30 | expect_equal(gcv(x)[["filename"]], files) 31 | 32 | gcv <- get_worldclim_precipitation(years = 2018, resolution = "5m") 33 | files <- sprintf("wc2.1_cruts4.09_5m_prec_2018-%02d.tif", 1:12) 34 | expect_equal(gcv(x)[["filename"]], files) 35 | 36 | expect_error(get_worldclim_precipitation(resolution = "na")) 37 | }) 38 | -------------------------------------------------------------------------------- /man/landcover.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_landcover.R 3 | \name{landcover} 4 | \alias{landcover} 5 | \alias{calc_landcover} 6 | \title{Calculate area of different landcover classes} 7 | \usage{ 8 | calc_landcover() 9 | } 10 | \value{ 11 | A function that returns an indicator tibble with landcover classes 12 | as variables and corresponding areas (in ha) as value. 13 | } 14 | \description{ 15 | The land cover data shows us how much of the region is covered by forests, 16 | rivers, wetlands, barren land, or urban infrastructure thus allowing the 17 | observation of land cover dynamics over a period of time. This function 18 | allows to efficiently calculate area of different landcover classes for 19 | polygons. For each polygon, the area of the classes in hectare(ha) is 20 | returned. 21 | } 22 | \details{ 23 | The required resources for this indicator are: 24 | \itemize{ 25 | \item \link{esalandcover} 26 | } 27 | } 28 | \examples{ 29 | \dontshow{ 30 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 31 | } 32 | \dontrun{ 33 | library(sf) 34 | library(mapme.biodiversity) 35 | 36 | outdir <- file.path(tempdir(), "mapme-data") 37 | dir.create(outdir, showWarnings = FALSE) 38 | 39 | mapme_options( 40 | outdir = outdir, 41 | verbose = FALSE 42 | ) 43 | 44 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 45 | package = "mapme.biodiversity" 46 | ) \%>\% 47 | read_sf() \%>\% 48 | get_resources(get_esalandcover(years = 2016:2017)) \%>\% 49 | calc_indicators(calc_landcover()) \%>\% 50 | portfolio_long() 51 | 52 | aoi 53 | } 54 | } 55 | \keyword{indicator} 56 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_precipitation_wc.R: -------------------------------------------------------------------------------- 1 | test_that("worldclim precipitation works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_worldclim_precipitation(years = 2018)) 13 | worldclim_precipitation <- prep_resources(x)[["worldclim_precipitation"]] 14 | 15 | cpwc <- calc_precipitation_wc() 16 | result <- cpwc(x, worldclim_precipitation) 17 | cpwc <- calc_precipitation_wc(stats = c("mean", "median", "sd")) 18 | result_multi_stat <- cpwc(x, worldclim_precipitation, ) 19 | cpwc <- calc_precipitation_wc(engine = "zonal") 20 | result_zonal <- cpwc(x, worldclim_precipitation) 21 | cpwc <- calc_precipitation_wc(engine = "extract") 22 | result_extract <- cpwc(x, worldclim_precipitation) 23 | cpwc <- calc_precipitation_wc(engine = "exactextract") 24 | result_exact <- cpwc(x, worldclim_precipitation) 25 | 26 | expect_silent(.check_single_asset(result)) 27 | expect_silent(.check_single_asset(result_multi_stat)) 28 | expect_silent(.check_single_asset(result_zonal)) 29 | expect_silent(.check_single_asset(result_extract)) 30 | expect_silent(.check_single_asset(result_exact)) 31 | 32 | vars <- c("worldclim_prec_mean", "worldclim_prec_median", "worldclim_prec_sd") 33 | expect_equal(unique(result_multi_stat$variable), vars) 34 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 35 | expect_snapshot(result_exact$value) 36 | }) 37 | -------------------------------------------------------------------------------- /man/key_biodiversity_areas_indicator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_key_biodiversity_areas.R 3 | \docType{data} 4 | \name{key_biodiversity_areas_indicator} 5 | \alias{key_biodiversity_areas_indicator} 6 | \alias{calc_key_biodiversity_area} 7 | \title{Calculate Key Biodiversity Areas} 8 | \format{ 9 | A function returning an indicator tibble with \code{key_biodiversity_area} 10 | as variable and the total overlap area (in ha) as value. 11 | } 12 | \usage{ 13 | calc_key_biodiversity_area() 14 | } 15 | \description{ 16 | This function calculates the total area of key biodiversity areas for a given 17 | input polygon. 18 | } 19 | \details{ 20 | The required resources for this indicator are: 21 | \itemize{ 22 | \item \link{key_biodiversity_areas_resource} 23 | } 24 | } 25 | \examples{ 26 | \dontshow{ 27 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 28 | } 29 | \dontrun{ 30 | library(sf) 31 | library(mapme.biodiversity) 32 | 33 | outdir <- file.path(tempdir(), "mapme-data") 34 | dir.create(outdir, showWarnings = FALSE) 35 | 36 | mapme_options( 37 | outdir = outdir, 38 | verbose = FALSE 39 | ) 40 | 41 | aoi <- read_sf( 42 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 43 | package = "mapme.biodiversity" 44 | )) 45 | kbas <- system.file("res", "key_biodiversity_areas", "kbas.gpkg", 46 | package = "mapme.biodiversity") 47 | aoi <- get_resources(aoi, get_key_biodiversity_areas(kbas)) 48 | aoi <- calc_indicators(aoi, calc_key_biodiversity_area()) 49 | aoi <- portfolio_long(aoi) 50 | 51 | aoi 52 | } 53 | } 54 | \keyword{indicator} 55 | -------------------------------------------------------------------------------- /man/key_biodiversity_areas_resource.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_key_biodiversity_areas.R 3 | \name{key_biodiversity_areas_resource} 4 | \alias{key_biodiversity_areas_resource} 5 | \alias{get_key_biodiversity_areas} 6 | \title{Key Biodiversity Areas} 7 | \source{ 8 | \url{https://www.keybiodiversityareas.org/request-gis-data} 9 | } 10 | \usage{ 11 | get_key_biodiversity_areas(path = NULL) 12 | } 13 | \arguments{ 14 | \item{path}{A character vector to the key biodiversity areas GPKG file. 15 | Note, that the file has to be downloaded manually.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprints object. 19 | } 20 | \description{ 21 | This resource contains outlines of key biodiversity areas, which are areas 22 | representing sites with specific importance for nature conservation. 23 | } 24 | \details{ 25 | To use this data in mapme workflows, you will have to manually download the 26 | global data set and point towards its file path on your local machine. 27 | Please find the available data under the source link given below. 28 | } 29 | \references{ 30 | BirdLife International (2024). The World Database of 31 | Key Biodiversity Areas. Developed by the KBA Partnership: BirdLife 32 | International, International Union for the Conservation of Nature, 33 | Amphibian Survival Alliance, Conservation International, Critical Ecosystem 34 | Partnership Fund, Global Environment Facility, Re:wild, NatureServe, 35 | Rainforest Trust, Royal Society for the Protection of Birds, Wildlife 36 | Conservation Society and World Wildlife Fund. Available at 37 | www.keybiodiversityareas.org. 38 | } 39 | \keyword{resource} 40 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_drought_indicator.R: -------------------------------------------------------------------------------- 1 | test_that("drought indicator works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_nasa_grace(years = 2022)) 13 | nasa_grace <- prep_resources(x)[["nasa_grace"]] 14 | 15 | cdi <- calc_drought_indicator() 16 | result <- cdi(x, nasa_grace) 17 | cdi <- calc_drought_indicator(stats = c("mean", "median", "sd")) 18 | result_multi_stats <- cdi(x, nasa_grace) 19 | cdi <- calc_drought_indicator(engine = "zonal") 20 | result_zonal <- cdi(x, nasa_grace) 21 | cdi <- calc_drought_indicator(engine = "extract") 22 | result_extract <- cdi(x, nasa_grace) 23 | cdi <- calc_drought_indicator(engine = "exactextract") 24 | result_exact <- cdi(x, nasa_grace) 25 | 26 | expect_silent(.check_single_asset(result[[1]])) 27 | expect_equal( 28 | unique(result_multi_stats[[1]]$variable), 29 | c("wetness_mean", "wetness_median", "wetness_sd") 30 | ) 31 | expect_equal( 32 | names(result_zonal), 33 | names(result_extract) 34 | ) 35 | expect_equal( 36 | names(result_zonal), 37 | names(result_exact) 38 | ) 39 | expect_equal( 40 | result[[1]]$value, 41 | result_zonal[[1]]$value, 42 | tolerance = 1e-4 43 | ) 44 | expect_equal( 45 | result_zonal[[1]]$value, 46 | result_extract[[1]]$value, 47 | tolerance = 1e-4 48 | ) 49 | expect_snapshot( 50 | result_exact[[1]]$value 51 | ) 52 | }) 53 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_key_biodiversity_areas.R: -------------------------------------------------------------------------------- 1 | test_that("calc_key_biodiversity_areas works", { 2 | sample_path <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 3 | package = "mapme.biodiversity") 4 | x <- read_sf(sample_path) 5 | x_area <- as.numeric(st_area(x)) 6 | x_area <- x_area / 10000 7 | 8 | .clear_resources() 9 | outdir <- tempfile() 10 | dir.create(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | 13 | get_resources(x, get_key_biodiversity_areas(path = sample_path)) 14 | kbas <- prep_resources(x)[["key_biodiversity_areas"]] 15 | 16 | kb <- calc_key_biodiversity_area() 17 | 18 | expect_null(kb(x, key_biodiversity_areas = NULL)) 19 | expect_null(kb(x, key_biodiversity_areas = head(x, 0))) 20 | 21 | result <- kb(x, kbas) 22 | expect_silent(.check_single_asset(result)) 23 | expect_equal(result$value, x_area, tolerance = 0.01) 24 | 25 | st_geometry(x) <- st_geometry(x) + 5 26 | st_crs(x) <- st_crs(4326) 27 | expect_equal(kb(x, kbas), NULL) 28 | 29 | mapme_options(chunk_size = 10000) 30 | x <- read_sf(sample_path) 31 | fname_kba <- system.file("res", "key_biodiversity_areas/kbas.gpkg", 32 | package = "mapme.biodiversity") 33 | res <- get_resources(x, get_key_biodiversity_areas(path = fname_kba)) 34 | kbas <- calc_indicators(res, calc_key_biodiversity_area()) 35 | kbas <- portfolio_long(kbas, drop_geoms = TRUE) 36 | 37 | area_kba <- st_area(read_sf(fname_kba)) 38 | area_kba <- as.numeric(area_kba) 39 | area_kba <- area_kba / 10000 40 | 41 | expect_equal( 42 | kbas$value, 43 | area_kba, 44 | tolerance = 0.01 45 | ) 46 | }) 47 | -------------------------------------------------------------------------------- /vignettes/workflow.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: "Darius A. Görgen" 3 | title: "Workflow" 4 | date: "Last modified: `r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Workflow} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>", 16 | fig.width = 5, 17 | fig.height = 5 18 | ) 19 | ``` 20 | 21 | The most important steps of the processing workflow of `{mapme.biodiversity}` 22 | are described here. A typical workflow consists of the following steps: 23 | 24 | - initialization of a portfolio object from an `{sf}` object together with portfolio-wide parameters set by `mapme_options()` 25 | - identify the required resources needed for the indicators you want to calculate 26 | - download one or more resources that are required for your desired indicators 27 | - automated calculation of the indicators for all assets within a portfolio 28 | - then, you are free to conduct your statistical analysis within R, or, 29 | - you can export the portfolio as a GeoPackage or other spatial data formats to 30 | share with others or use it with other Geo-spatial software (e.g. QGIS) 31 | 32 | ```{r wflow, echo = FALSE} 33 | library(DiagrammeR) 34 | 35 | mermaid(" 36 | graph TB 37 | 38 | classDef default fill:#c2dddd,stroke-width:2px,stroke:#034858; 39 | 40 | A(Portfolio initialization) 41 | B(Get resources) 42 | C(Calculate indicators) 43 | D(Statistical analysis within R) 44 | E(Export to GeoPackage) 45 | A-->B 46 | B-->C 47 | C-->D 48 | C-->E 49 | 50 | ") 51 | ``` 52 | 53 | -------------------------------------------------------------------------------- /man/gsw_seasonality.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_gsw_seasonality.R 3 | \name{gsw_seasonality} 4 | \alias{gsw_seasonality} 5 | \alias{calc_gsw_seasonality} 6 | \title{Calculate Global Surface Water (GSW) Seasonality} 7 | \usage{ 8 | calc_gsw_seasonality() 9 | } 10 | \value{ 11 | A function that returns an indicator tibble with seasonality 12 | categories as variables and corresponding areas (in ha) as value. 13 | } 14 | \description{ 15 | GSW seasonality describes the intra-annual distribution of surface water for 16 | each pixel. The raster files have integer cell values between \code{[0, 12]}, 17 | indicating how many months per year the pixel was classified as water. 18 | } 19 | \details{ 20 | The pixel values are aggregated using method provided via the 21 | \code{stats} parameter. 22 | 23 | The required resources for this indicator are: 24 | \itemize{ 25 | \item \link{global_surface_water_seasonality} 26 | } 27 | } 28 | \examples{ 29 | \dontshow{ 30 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 31 | } 32 | \dontrun{ 33 | library(sf) 34 | library(mapme.biodiversity) 35 | 36 | outdir <- file.path(tempdir(), "mapme-data") 37 | dir.create(outdir, showWarnings = FALSE) 38 | 39 | mapme_options( 40 | outdir = outdir, 41 | verbose = FALSE 42 | ) 43 | 44 | aoi <- system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 45 | package = "mapme.biodiversity" 46 | ) \%>\% 47 | read_sf() \%>\% 48 | get_resources(get_global_surface_water_seasonality()) \%>\% 49 | calc_indicators(calc_gsw_seasonality()) \%>\% 50 | portfolio_long() 51 | 52 | aoi 53 | } 54 | } 55 | \keyword{indicator} 56 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_traveltime_2000.R: -------------------------------------------------------------------------------- 1 | test_that("traveltime_2000 works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme-data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_accessibility_2000()) 12 | accessibility_2000 <- prep_resources(x)[["accessibility_2000"]] 13 | 14 | ctt_2000 <- calc_traveltime_2000() 15 | expect_true(is.null(ctt_2000(x, NULL))) 16 | result <- ctt_2000(x, accessibility_2000) 17 | ctt_2000 <- calc_traveltime_2000(stats = c("mean", "median", "sd")) 18 | result_multi_stat <- ctt_2000(x, accessibility_2000) 19 | ctt_2000 <- calc_traveltime_2000(engine = "zonal") 20 | result_zonal <- ctt_2000(x, accessibility_2000) 21 | ctt_2000 <- calc_traveltime_2000(engine = "extract") 22 | result_extract <- ctt_2000(x, accessibility_2000) 23 | ctt_2000 <- calc_traveltime_2000(engine = "exactextract") 24 | result_exact <- ctt_2000(x, accessibility_2000) 25 | 26 | expect_silent(.check_single_asset(result)) 27 | expect_silent(.check_single_asset(result_multi_stat)) 28 | expect_silent(.check_single_asset(result_zonal)) 29 | expect_silent(.check_single_asset(result_extract)) 30 | expect_silent(.check_single_asset(result_exact)) 31 | 32 | vars <- c("traveltime_2000_mean", "traveltime_2000_median", "traveltime_2000_sd") 33 | expect_equal(unique(result_multi_stat$variable), vars) 34 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 35 | expect_snapshot(result_exact$value) 36 | }) 37 | -------------------------------------------------------------------------------- /man/teow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_teow.R 3 | \name{teow} 4 | \alias{teow} 5 | \alias{get_teow} 6 | \title{Terrestrial Ecoregions of the World (TEOW) Polygon} 7 | \source{ 8 | \url{https://files.worldwildlife.org/wwfcmsprod/files/Publication/file/6kcchn7e3u_official_teow.zip} 9 | } 10 | \usage{ 11 | get_teow(path = NULL) 12 | } 13 | \arguments{ 14 | \item{path}{A character vector to the Terrestrial Ecoregions of the World (TEOW) 15 | zip file. Note, that the file has to be downloaded manually.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This resource is part of the publication by Olson et al. (2004) 22 | "Terrestrial Ecosystems of the World (TEOW) from WWF-US (Olson)". It 23 | depicts 867 terrestrial ecoregions around the world classified into 14 24 | different terrestrial biomes such as forests, grasslands, or deserts. 25 | The polygons represent the ecoregions, defined as relatively large units of 26 | land or inland water sharing a large majority of biodiversity. The datasets 27 | is made available from World Wildlife Fund (WWF) for the year 2001. 28 | } 29 | \references{ 30 | Olson, D. M., Dinerstein, E., Wikramanayake, E. D., Burgess, N. D., 31 | Powell, G. V. N., Underwood, E. C., D’Amico, J. A., Itoua, I., Strand, H. E., 32 | Morrison, J. C., Loucks, C. J., Allnutt, T. F., Ricketts, T. H., Kura, Y., Lamoreux, 33 | J. F., Wettengel, W. W., Hedao, P., Kassem, K. R. 2001. Terrestrial ecoregions of 34 | the world: a new map of life on Earth. Bioscience 51(11):933-938. 35 | \doi{doi:10.1641/0006-3568(2001)051[0933:TEOTWA]2.0.CO;2} 36 | } 37 | \keyword{resource} 38 | -------------------------------------------------------------------------------- /man/fritz_et_al.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_fritz_et_al.R 3 | \name{fritz_et_al} 4 | \alias{fritz_et_al} 5 | \alias{get_fritz_et_al} 6 | \title{Drivers of deforestation for tropical forests} 7 | \source{ 8 | \url{https://zenodo.org/record/7997885} 9 | } 10 | \usage{ 11 | get_fritz_et_al(resolution = 100) 12 | } 13 | \arguments{ 14 | \item{resolution}{An integer indicating the resolution 15 | to download. Defaults to 100.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | This resource is produced by a nearest-neighbour matching of a crowd-sourced 22 | campaign to map dominant driver of forest loss based on visual interpretation 23 | of VHR images matched with Global Forest Loss data by Hansen (2013) version 24 | 1.7 The forest loss layer was re sampled to a resolution of 100 and 1.000 25 | meters. Dominant drivers were determined for the period 2008 to 2009. 26 | } 27 | \details{ 28 | It indicates 9 different classes: 29 | \itemize{ 30 | \item commercial agriculture 31 | \item commercial oil palm plantations 32 | \item managed forests 33 | \item mining 34 | \item natural disturbances 35 | \item pasture 36 | \item roads 37 | \item wildfire 38 | \item other subsistence agriculture 39 | \item shifting cultivation 40 | } 41 | } 42 | \references{ 43 | Steffen, F., Carlos, J.C.L., See. L., Schepaschenko D., 44 | Hofhansl F., Jung M., Dürauer M., Georgieva I., Danylo O., Lesiv M., 45 | McCallum I. (2022) A Continental Assessment of the Drivers of Tropical 46 | Deforestation With a Focus on Protected Areas. F.Cos.Sc.(3) 47 | doi:10.3389/fcosc.2022.830248 48 | } 49 | \keyword{resource} 50 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | release: 9 | types: [published] 10 | schedule: 11 | - cron: "0 4 * * *" 12 | workflow_dispatch: 13 | 14 | name: pkgdown 15 | 16 | jobs: 17 | pkgdown: 18 | runs-on: ubuntu-latest 19 | env: 20 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 21 | steps: 22 | - uses: actions/checkout@v4 23 | 24 | - uses: r-lib/actions/setup-pandoc@v2 25 | 26 | - uses: r-lib/actions/setup-r@v2 27 | with: 28 | use-public-rspm: true 29 | 30 | - uses: r-lib/actions/setup-r-dependencies@v2 31 | with: 32 | extra-packages: any::pkgdown, local::. 33 | needs: website 34 | 35 | - name: Deploy package 36 | if: github.event_name != 'pull_request' 37 | run: | 38 | git config --local user.name "$GITHUB_ACTOR" 39 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 40 | Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, run_dont_run = TRUE)' 41 | 42 | - name: Build site without deploying 43 | if: github.event_name == 'pull_request' 44 | run: | 45 | Rscript -e 'pkgdown::build_site_github_pages(dest_dir = "docs", run_dont_run = TRUE)' 46 | 47 | - uses: actions/upload-artifact@v4 48 | if: github.event_name == 'pull_request' 49 | with: 50 | name: pkgdown_build 51 | path: docs/ 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /man/chelsa.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_chelsa.R 3 | \name{chelsa} 4 | \alias{chelsa} 5 | \alias{get_chelsa} 6 | \title{Climatologies at High resolution for the Earth Land Surface Areas (CHELSA)} 7 | \source{ 8 | \url{https://envicloud.wsl.ch/#/?prefix=chelsa/chelsa_V2/GLOBAL/} 9 | } 10 | \usage{ 11 | get_chelsa(years = 1979:2019) 12 | } 13 | \arguments{ 14 | \item{years}{A numeric vector of the years to make CHELSA monthly precipitation 15 | layers available for. Must be greater 1979, defaults to \code{c(1979:2019)}.} 16 | } 17 | \value{ 18 | A function that returns an \code{sf} footprint object. 19 | } 20 | \description{ 21 | The CHELSA data (Karger et al. 2017) consists of downscaled model output 22 | temperature and precipitation estimates at a horizontal resolution of 30 arc 23 | sec. The precipitation algorithm incorporates orographic predictors including 24 | wind fields, valley exposition, and boundary layer height, with a subsequent 25 | bias correction. The spatial resolution is about 1-arc second (~1km at the 26 | equator). This resource makes V2 available. 27 | } 28 | \references{ 29 | Karger, D.N., Conrad, O., Böhner, J., Kawohl, T., Kreft, H., 30 | Soria-Auza, R.W., Zimmermann, N.E., Linder, H.P. & Kessler, M. (2021) 31 | Climatologies at high resolution for the earth’s land surface areas. 32 | EnviDat. \doi{doi:10.16904/envidat.228.v2.1} 33 | 34 | Karger, D.N., Conrad, O., Böhner, J., Kawohl, T., Kreft, H., Soria-Auza, 35 | R.W., Zimmermann, N.E., Linder, P., Kessler, M. (2017): Climatologies at high 36 | resolution for the Earth land surface areas. Scientific Data. 4 37 | 170122. \doi{doi:10.1038/sdata.2017.122} 38 | } 39 | \keyword{resource} 40 | -------------------------------------------------------------------------------- /man/gfw_treecover.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gfw_treecover.R 3 | \name{gfw_treecover} 4 | \alias{gfw_treecover} 5 | \alias{get_gfw_treecover} 6 | \title{Treecover for the year 2000} 7 | \source{ 8 | \url{https://data.globalforestwatch.org/documents/tree-cover-2000/explore} 9 | } 10 | \usage{ 11 | get_gfw_treecover(version = "GFC-2024-v1.12") 12 | } 13 | \arguments{ 14 | \item{version}{The version of the dataset to download. Defaults to 15 | "GFC-2024-v1.12". Check mapme.biodiversity:::.available_gfw_versions() 16 | to get a list of available versions} 17 | } 18 | \value{ 19 | A function that returns an \code{sf} footprint object. 20 | } 21 | \description{ 22 | This resource is part of the publication by Hansen et al. (2013) 23 | represents "tree cover in the year 2000, defined as canopy closure for all 24 | vegetation taller than 5m in height. Encoded as a percentage per output grid 25 | cell, in the range 0–100." Due to changes in the satellites products used 26 | in the compilation of the treecover product, results before the year 2011 27 | and afterwards are not directly comparable until reprocessing has finished. 28 | Users should be aware of this limitation, especially when the timeframe 29 | of the analysis spans over the two periods delimited by the year 2011. 30 | } 31 | \references{ 32 | Hansen, M. C., P. V. Potapov, R. Moore, M. Hancher, S. A. 33 | Turubanova, A. Tyukavina, D. Thau, S. V. Stehman, S. J. Goetz, T. R. 34 | Loveland, A. Kommareddy, A. Egorov, L. Chini, C. O. Justice, and J. R. G. 35 | Townshend. 2013. “High-Resolution Global Maps of 21st-Century Forest Cover 36 | Change.” Science 342 (15 November): 850–53. 37 | } 38 | \keyword{resource} 39 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_temperature_max_wc.R: -------------------------------------------------------------------------------- 1 | test_that("worldclim maximum temperature works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_worldclim_max_temperature(years = 2018)) 13 | worldclim_max_temperature <- prep_resources(x)[["worldclim_max_temperature"]] 14 | 15 | cmx <- calc_temperature_max_wc() 16 | expect_true(is.null(cmx(x, NULL))) 17 | 18 | result <- cmx(x, worldclim_max_temperature) 19 | cmx <- calc_temperature_max_wc(stats = c("mean", "median", "sd")) 20 | result_multi_stat <- cmx(x, worldclim_max_temperature) 21 | cmx <- calc_temperature_max_wc(engine = "zonal") 22 | result_zonal <- cmx(x, worldclim_max_temperature) 23 | cmx <- calc_temperature_max_wc(engine = "extract") 24 | result_extract <- cmx(x, worldclim_max_temperature) 25 | cmx <- calc_temperature_max_wc(engine = "exactextract") 26 | result_exact <- cmx(x, worldclim_max_temperature) 27 | 28 | expect_silent(.check_single_asset(result)) 29 | expect_silent(.check_single_asset(result_multi_stat)) 30 | expect_silent(.check_single_asset(result_zonal)) 31 | expect_silent(.check_single_asset(result_extract)) 32 | expect_silent(.check_single_asset(result_exact)) 33 | 34 | vars <- c("worldclim_tmax_mean", "worldclim_tmax_median", "worldclim_tmax_sd") 35 | expect_equal(unique(result_multi_stat$variable), vars) 36 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 37 | expect_snapshot(result_exact$value) 38 | }) 39 | -------------------------------------------------------------------------------- /man/biodiversity_intactness_index_indicator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_biodiversity_intactness_index.R 3 | \docType{data} 4 | \name{biodiversity_intactness_index_indicator} 5 | \alias{biodiversity_intactness_index_indicator} 6 | \alias{calc_biodiversity_intactness_index} 7 | \title{Calculate Biodiversity Intactness Index} 8 | \format{ 9 | A function that returns an indicator tibble with variable 10 | biodiversity_intactness_index and corresponding values (unitless) as value. 11 | } 12 | \usage{ 13 | calc_biodiversity_intactness_index() 14 | } 15 | \description{ 16 | This function calculates the mean biodiversity intactness index for a region. 17 | } 18 | \details{ 19 | The required resources for this indicator are: 20 | \itemize{ 21 | \item \link{biodiversity_intactness_index_resource} 22 | } 23 | } 24 | \examples{ 25 | \dontshow{ 26 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 27 | } 28 | \dontrun{ 29 | library(sf) 30 | library(mapme.biodiversity) 31 | 32 | outdir <- file.path(tempdir(), "mapme-data") 33 | dir.create(outdir, showWarnings = FALSE) 34 | 35 | mapme_options( 36 | outdir = outdir, 37 | verbose = FALSE 38 | ) 39 | 40 | lbii <- system.file("res", "biodiversity_intactness_index", "lbii.asc", 41 | package = "mapme.biodiversity") 42 | 43 | aoi <- read_sf( 44 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 45 | package = "mapme.biodiversity" 46 | )) 47 | aoi <- get_resources(aoi, get_biodiversity_intactness_index(lbii)) 48 | aoi <- calc_indicators(aoi, calc_biodiversity_intactness_index()) 49 | aoi <- portfolio_long(aoi) 50 | 51 | aoi 52 | } 53 | } 54 | \keyword{indicator} 55 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_temperature_min_wc.R: -------------------------------------------------------------------------------- 1 | test_that("worldclim minimum temperature works", { 2 | x <- read_sf( 3 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | get_resources(x, get_worldclim_min_temperature(years = 2018)) 13 | worldclim_min_temperature <- prep_resources(x)[["worldclim_min_temperature"]] 14 | 15 | cmin <- calc_temperature_min_wc() 16 | expect_true(is.null(cmin(x, NULL))) 17 | result <- cmin(x, worldclim_min_temperature) 18 | cmin <- calc_temperature_min_wc(stats = c("mean", "median", "sd")) 19 | result_multi_stat <- cmin(x, worldclim_min_temperature) 20 | cmin <- calc_temperature_min_wc(engine = "zonal") 21 | result_zonal <- cmin(x, worldclim_min_temperature) 22 | cmin <- calc_temperature_min_wc(engine = "extract") 23 | result_extract <- cmin(x, worldclim_min_temperature) 24 | cmin <- calc_temperature_min_wc(engine = "exactextract") 25 | result_exact <- cmin(x, worldclim_min_temperature) 26 | 27 | expect_silent(.check_single_asset(result)) 28 | expect_silent(.check_single_asset(result_multi_stat)) 29 | expect_silent(.check_single_asset(result_zonal)) 30 | expect_silent(.check_single_asset(result_extract)) 31 | expect_silent(.check_single_asset(result_exact)) 32 | 33 | 34 | vars <- c("worldclim_tmin_mean", "worldclim_tmin_median", "worldclim_tmin_sd") 35 | expect_equal(unique(result_multi_stat$variable), vars) 36 | expect_equal(result_zonal$value, result_extract$value, tolerance = 1e-4) 37 | expect_snapshot(result_exact$value) 38 | }) 39 | -------------------------------------------------------------------------------- /man/global_surface_water_occurrence.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gsw.R 3 | \name{global_surface_water_occurrence} 4 | \alias{global_surface_water_occurrence} 5 | \alias{get_global_surface_water_occurrence} 6 | \title{Global Surface Water Occurrence} 7 | \source{ 8 | \url{https://global-surface-water.appspot.com/} 9 | } 10 | \usage{ 11 | get_global_surface_water_occurrence(version = "v1_4_2021") 12 | } 13 | \arguments{ 14 | \item{version}{A character vector indicating the version of the GSW data set 15 | to make available.} 16 | } 17 | \value{ 18 | A character of file paths. 19 | } 20 | \description{ 21 | The Global Surface Water dataset was developed by the European Commission's 22 | Joint Research Centre in the framework of the Copernicus Programme. It maps 23 | the location and temporal distribution of water surfaces at the global scale 24 | over the past 3.8 decades and provides statistics on their extent and change. 25 | It is provisioned as a global tiled raster resource available for all land 26 | areas. The reported data represent aggregated observations between 1984 - 2021. 27 | } 28 | \details{ 29 | GSW occurrence raw data comes in raster files with integer cell values 30 | between \code{[0, 100]}. This value gives the percentage of the time that a 31 | given pixel was classified as water during the entire observation period. So 32 | a 0 denotes a pixel that was never classified as water, 100 denotes a pixel 33 | with permanent water. 34 | } 35 | \references{ 36 | Pekel, JF., Cottam, A., Gorelick, N. et al. High-resolution 37 | mapping of global surface water and its long-term changes. Nature 540, 38 | 418–422 (2016). \doi{doi:10.1038/nature20584} 39 | } 40 | \keyword{resource} 41 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_gsw_time_series.R: -------------------------------------------------------------------------------- 1 | test_that("calc_gsw_time_series works", { 2 | aoi <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | outdir_gsw <- file.path(outdir, "gsw_time_series") 13 | 14 | gsw_fnames_short <- dir(outdir_gsw, pattern = ".tif$") 15 | gsw_fnames_long <- sub("v5_", "VER5-0_yearlyClassification", gsw_fnames_short) 16 | file.copy( 17 | file.path(outdir_gsw, gsw_fnames_short), 18 | file.path(outdir_gsw, gsw_fnames_long) 19 | ) 20 | 21 | res <- calc_indicators( 22 | get_resources( 23 | aoi, get_gsw_time_series(years = 2000) 24 | ), 25 | calc_gsw_time_series() 26 | ) 27 | expect_equal( 28 | nrow(res$gsw_timeseries [[1]]), 29 | 4 30 | ) 31 | 32 | years <- 2000:2001 33 | aoi <- get_resources(aoi, get_gsw_time_series(years)) 34 | res <- calc_indicators(aoi, calc_gsw_time_series()) 35 | res <- res$gsw_timeseries [[1]] 36 | 37 | file.remove( 38 | file.path(outdir_gsw, gsw_fnames_long) 39 | ) 40 | 41 | expect_equal( 42 | res$datetime, 43 | rep(as.POSIXct(c("2000-01-01T00:00:00Z", "2001-01-01T00:00:00Z")), 4) 44 | ) 45 | 46 | expect_equal( 47 | res$variable, 48 | rep(c("no_observations", "not_water", "seasonal_water", "permanent_water"), each = 2) 49 | ) 50 | 51 | expect_equal( 52 | res$unit, 53 | rep("ha", 8) 54 | ) 55 | 56 | expect_equal( 57 | res$value, 58 | c(2684.78, 2635.35, 13.99, 0.00, 337.11, 327.85, 129.96, 202.64), 59 | tolerance = 0.1 60 | ) 61 | }) 62 | -------------------------------------------------------------------------------- /man/gfw_emissions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gfw_emissions.R 3 | \name{gfw_emissions} 4 | \alias{gfw_emissions} 5 | \alias{get_gfw_emissions} 6 | \title{Forest greenhouse gas emissions} 7 | \source{ 8 | \url{https://data.globalforestwatch.org/datasets/gfw::forest-greenhouse-gas-emissions/about} 9 | } 10 | \usage{ 11 | get_gfw_emissions() 12 | } 13 | \value{ 14 | A function that returns an \code{sf} footprint object. 15 | } 16 | \description{ 17 | This resource is part of the publication by Harris et al. (2021) 18 | "Global maps of twenty-first century forest carbon fluxes.". It 19 | represents "the greenhouse gas 20 | emissions arising from stand-replacing forest disturbances that occurred in 21 | each modelled year (megagrams CO2 emissions/ha, between 2001 and 2023). 22 | Emissions include all relevant ecosystem carbon pools (aboveground biomass, 23 | belowground biomass, dead wood, litter, soil) and greenhouse gases (CO2, CH4, 24 | N2O)." The area unit that is downloaded here corresponds to the 25 | "megagrams of CO2 emissions/pixel" layer, in order to support the calculation 26 | of area-wise emissions. 27 | } 28 | \details{ 29 | There are no arguments users need to specify. However, users should note 30 | that the spatial extent for this dataset does not totally cover the same 31 | extent as the \code{treecover2000} and \code{lossyear} resources by Hansen 32 | et al. (2013). A missing value (NA) will be inserted for greenhouse gas 33 | emissions for areas where no data is available. 34 | } 35 | \references{ 36 | Harris, N.L., Gibbs, D.A., Baccini, A. et al. Global maps of 37 | twenty-first century forest carbon fluxes. Nat. Clim. Chang. 11, 234–240 38 | (2021). \doi{doi:10.1038/s41558-020-00976-6} 39 | } 40 | \keyword{resource} 41 | -------------------------------------------------------------------------------- /man/elevation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_elevation.R 3 | \name{elevation} 4 | \alias{elevation} 5 | \alias{calc_elevation} 6 | \title{Calculate elevation statistics} 7 | \usage{ 8 | calc_elevation(engine = "extract", stats = "mean") 9 | } 10 | \arguments{ 11 | \item{engine}{The preferred processing functions from either one of "zonal", 12 | "extract" or "exactextract" as character.} 13 | 14 | \item{stats}{Function to be applied to compute statistics for polygons either 15 | one or multiple inputs as character "mean", "median" or "sd".} 16 | } 17 | \value{ 18 | A function that returns an indicator tibble with specified elevation 19 | statistics as variable and corresponding values (in meters) as value. 20 | } 21 | \description{ 22 | This function allows to calculate elevation statistics for 23 | polygons. For each polygon, the desired statistic(s) 24 | are returned. 25 | } 26 | \details{ 27 | The required resources for this indicator are: 28 | \itemize{ 29 | \item \link{nasa_srtm} 30 | } 31 | } 32 | \examples{ 33 | \dontshow{ 34 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 35 | } 36 | \dontrun{ 37 | library(sf) 38 | library(mapme.biodiversity) 39 | 40 | outdir <- file.path(tempdir(), "mapme-data") 41 | dir.create(outdir, showWarnings = FALSE) 42 | 43 | mapme_options( 44 | outdir = outdir, 45 | verbose = FALSE 46 | ) 47 | 48 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 49 | package = "mapme.biodiversity" 50 | ) \%>\% 51 | read_sf() \%>\% 52 | get_resources(get_nasa_srtm()) \%>\% 53 | calc_indicators( 54 | calc_elevation(engine = "extract", stats = c("mean", "median", "sd", "var")) 55 | ) \%>\% 56 | portfolio_long() 57 | 58 | aoi 59 | } 60 | } 61 | \keyword{indicator} 62 | -------------------------------------------------------------------------------- /man/slope.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_slope.R 3 | \name{slope} 4 | \alias{slope} 5 | \alias{calc_slope} 6 | \title{Calculate slope statistics} 7 | \usage{ 8 | calc_slope(engine = "exactextract", stats = "mean") 9 | } 10 | \arguments{ 11 | \item{engine}{The preferred processing function from either one of "zonal", 12 | "extract" or "exactextract" as a character string.} 13 | 14 | \item{stats}{Function to be applied to compute statistics for polygons. 15 | Accepts either a single string or a vector of strings, such as "mean", 16 | "median", "sd", "min", "max", "sum", or "var".} 17 | } 18 | \value{ 19 | A function that returns an indicator tibble with specified slope 20 | statistics as variables and corresponding values (in degrees). 21 | } 22 | \description{ 23 | This function allows to calculate slope statistics for 24 | polygons. For each polygon, the desired statistic(s) 25 | are returned. 26 | } 27 | \details{ 28 | The required resource for this indicator is: 29 | \itemize{ 30 | \item \link{nasa_srtm} 31 | } 32 | } 33 | \examples{ 34 | \dontshow{ 35 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 36 | } 37 | \dontrun{ 38 | library(sf) 39 | library(mapme.biodiversity) 40 | 41 | outdir <- file.path(tempdir(), "mapme-data") 42 | dir.create(outdir, showWarnings = FALSE) 43 | 44 | mapme_options( 45 | outdir = outdir, 46 | verbose = FALSE 47 | ) 48 | 49 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 50 | package = "mapme.biodiversity" 51 | ) \%>\% 52 | read_sf() \%>\% 53 | get_resources(get_nasa_srtm()) \%>\% 54 | calc_indicators( 55 | calc_slope(stats = c("mean", "median", "sd", "var"), engine = "extract") 56 | ) \%>\% 57 | portfolio_long() 58 | 59 | aoi 60 | } 61 | } 62 | \keyword{indicator} 63 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_precipitation_chirps.R: -------------------------------------------------------------------------------- 1 | # This test was deactivated because calls to the CHIRPS website would fail. 2 | # TODO: reactivate this test 3 | # test_that("precipitation indicator works", { 4 | # skip_on_cran() 5 | # x <- read_sf( 6 | # system.file("extdata", "gfw_sample.gpkg", 7 | # package = "mapme.biodiversity" 8 | # ) 9 | # ) 10 | # .clear_resources() 11 | # outdir <- file.path(tempdir(), "mapme.data") 12 | # .copy_resource_dir(outdir) 13 | # mapme_options(outdir = outdir, verbose = FALSE) 14 | # get_resources(x, get_chirps(years = 2010)) 15 | # chirps <- prep_resources(x)[["chirps"]] 16 | # 17 | # expect_message(cpc <- calc_precipitation_chirps(1980:1982)) 18 | # expect_error(calc_precipitation_chirps(years = 1970:1971)) 19 | # expect_error(calc_precipitation_chirps(years = 1981:1982, engine = "not-av")) 20 | # expect_true(is.null(cpc(x, NULL))) 21 | # cpc <- calc_precipitation_chirps(years = 2010) 22 | # result <- cpc(x, chirps) 23 | # cpc <- calc_precipitation_chirps(years = 2010, engine = "zonal") 24 | # result_zonal <- cpc(x, chirps) 25 | # cpc <- calc_precipitation_chirps(years = 2010, engine = "extract") 26 | # result_extract <- cpc(x, chirps) 27 | # cpc <- calc_precipitation_chirps(years = 2010, engine = "exactextract") 28 | # result_exact <- cpc(x, chirps) 29 | # 30 | # expect_silent(.check_single_asset(result[[1]])) 31 | # expect_silent(.check_single_asset(result_zonal[[1]])) 32 | # expect_silent(.check_single_asset(result_extract[[1]])) 33 | # expect_silent(.check_single_asset(result_exact[[1]])) 34 | # 35 | # expect_equal(unique(result[[1]]$variable), "precipitation") 36 | # expect_equal(result_zonal[[1]]$value, result_extract[[1]]$value, 37 | # tolerance = 1e-4 38 | # ) 39 | # expect_snapshot(result[[1]]$value) 40 | # }) 41 | -------------------------------------------------------------------------------- /tests/testthat/test-get_gsw.R: -------------------------------------------------------------------------------- 1 | test_that(".get_gsw works", { 2 | skip_on_cran() 3 | 4 | x <- read_sf( 5 | system.file("extdata", "sierra_de_neiba_478140.gpkg", 6 | package = "mapme.biodiversity" 7 | ) 8 | ) 9 | 10 | expect_error(.get_gsw(x, statistic = "not-available")) 11 | expect_error(.get_gsw(x, version = "not-available")) 12 | 13 | gsw <- get_global_surface_water_change() 14 | expect_silent(.check_resource_fun(gsw)) 15 | expect_silent(fps <- gsw(x)) 16 | expect_silent(.check_footprints(fps)) 17 | expect_equal(fps$filename, "change_80W_20Nv1_4_2021.tif") 18 | 19 | gsw <- get_global_surface_water_transitions() 20 | expect_silent(.check_resource_fun(gsw)) 21 | expect_silent(fps <- gsw(x)) 22 | expect_silent(.check_footprints(fps)) 23 | expect_equal(fps$filename, "transitions_80W_20Nv1_4_2021.tif") 24 | 25 | gsw <- get_global_surface_water_seasonality() 26 | expect_silent(.check_resource_fun(gsw)) 27 | expect_silent(fps <- gsw(x)) 28 | expect_silent(.check_footprints(fps)) 29 | expect_equal(fps$filename, "seasonality_80W_20Nv1_4_2021.tif") 30 | 31 | gsw <- get_global_surface_water_recurrence() 32 | expect_silent(.check_resource_fun(gsw)) 33 | expect_silent(fps <- gsw(x)) 34 | expect_silent(.check_footprints(fps)) 35 | expect_equal(fps$filename, "recurrence_80W_20Nv1_4_2021.tif") 36 | 37 | gsw <- get_global_surface_water_occurrence() 38 | expect_silent(.check_resource_fun(gsw)) 39 | expect_silent(fps <- gsw(x)) 40 | expect_silent(.check_footprints(fps)) 41 | expect_equal(fps$filename, "occurrence_80W_20Nv1_4_2021.tif") 42 | 43 | # adds test to check for multiple polygons in the same tile 44 | x_split <- st_as_sf(st_make_grid(x, n = 2)) 45 | expect_silent(fps <- .get_gsw(x_split, statistic = "occurrence")) 46 | expect_equal(nrow(fps), 1) 47 | }) 48 | -------------------------------------------------------------------------------- /man/indicators.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/register.R 3 | \name{indicators} 4 | \alias{indicators} 5 | \alias{register_indicator} 6 | \alias{available_indicators} 7 | \title{Register or list indicators in mapme.biodiversity} 8 | \usage{ 9 | register_indicator(name = NULL, description = NULL, resources = NULL) 10 | 11 | available_indicators(indicators = NULL) 12 | } 13 | \arguments{ 14 | \item{name}{A character vector indicating the name of the indicator.} 15 | 16 | \item{description}{A character vector with a basic description} 17 | 18 | \item{resources}{A character vector of the required resources 19 | that need to be available to calculate the indicator. The names must 20 | correspond with already registered resources.} 21 | 22 | \item{indicators}{If \code{NULL} returns a list of all registered indicators 23 | (default). Otherwise only the ones specified.} 24 | } 25 | \value{ 26 | \code{register_indicator()} is called for the side-effect of registering 27 | an indicator 28 | 29 | \code{available_resources()} returns a tibble listing available indicators. 30 | } 31 | \description{ 32 | \code{register_indicator()} is used to register a new indicator function with base 33 | information to the package's internal environment used to inform users about 34 | available indicators. Note, registering a custom indicator will 35 | only have effect for the current R session. 36 | 37 | \code{available_indicators()} returns a tibble of registered indicators with basic 38 | information such as the required resources. 39 | } 40 | \examples{ 41 | \dontrun{ 42 | register_indicator( 43 | name = "treecover_area", 44 | description = "Area of forest cover by year", 45 | resources = c( 46 | "gfw_treecover", 47 | "gfw_lossyear" 48 | ) 49 | ) 50 | } 51 | available_indicators() 52 | } 53 | -------------------------------------------------------------------------------- /tests/testthat/test-calc_fatalities_ucpd.R: -------------------------------------------------------------------------------- 1 | test_that(".calc_fatalities_ucpd works", { 2 | x <- read_sf( 3 | system.file("extdata", "burundi.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | .clear_resources() 8 | outdir <- file.path(tempdir(), "mapme.data") 9 | .copy_resource_dir(outdir) 10 | mapme_options(outdir = outdir, verbose = FALSE) 11 | get_resources(x, get_ucdp_ged(version = "22.1")) 12 | ucdp_ged <- prep_resources(x)[["ucdp_ged"]][[1]] 13 | 14 | expect_error( 15 | calc_fatalities_ucdp(years = 1980), 16 | "The target years do not intersect with the availability of ucdp_ged." 17 | ) 18 | expect_error( 19 | calc_fatalities_ucdp(precision_location = 8), 20 | "Argument precision_location must be a single numeric between 1 and 7." 21 | ) 22 | expect_error( 23 | calc_fatalities_ucdp(precision_time = 6), 24 | "Argument precision_time must be a single numeric between 1 and 5." 25 | ) 26 | 27 | cf <- calc_fatalities_ucdp(years = 1991:1992) 28 | result_default <- cf(x, list(ucdp_ged)) 29 | cf <- calc_fatalities_ucdp(years = 1991:1992, precision_location = 7, precision_time = 5) 30 | result_all <- cf(x, list(ucdp_ged)) 31 | 32 | conf_types <- c("state_based_conflict", "non_state_conflict", "one_sided_violence") 33 | death_types <- c("deaths_civilians", "deaths_unknown", "deaths_total") 34 | vars <- paste("fatalities", rep(conf_types, each = length(death_types)), death_types, sep = "_") 35 | 36 | expect_silent(.check_single_asset(result_default)) 37 | expect_equal(unique(result_default$variable), vars[7:9]) 38 | expect_equal(nrow(result_default), 3) 39 | expect_equal(sum(result_default$value), 40) 40 | 41 | expect_equal(unique(result_all$variable), vars[-c(4:6)]) 42 | expect_equal(nrow(result_all), 9) 43 | expect_equal(sum(result_all$value), 592) 44 | }) 45 | -------------------------------------------------------------------------------- /vignettes/installation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{Installation} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>" 14 | ) 15 | ``` 16 | 17 | 18 | This section describes how to install the `{mapme.biodiversity}` package. 19 | Since the package handles spatial data, we assume that you have 20 | a working installation of [GDAL](https://gdal.org/index.html) and [PROJ](https://proj.org/) 21 | on your system. Our recommendation is to follow the `{sf}` installation instructions. 22 | 23 | While the package supports sequentially downloading all supported resources, 24 | we include the option to provide a path to an [aria2](https://aria2.github.io/) executable 25 | to speed up downloads based on parallel processing. We expect that 26 | the path to the executable binary is known to the user and we test if it is actually executable. 27 | 28 | Given that the above requirements are met, installing the `{mapme.biodiversity}` 29 | current CRAN release is then achieved through the following function call: 30 | 31 | ```{r installation-cran, eval = FALSE} 32 | install.packages("mapme.biodiversity") 33 | ``` 34 | 35 | You can install the latest development version from GitHub via the following 36 | call: 37 | 38 | ```{r installation, eval = FALSE} 39 | remotes::install_github("mapme-initiative/mapme.biodiversity") 40 | ``` 41 | 42 | The installation process will install potential missing R dependencies. 43 | After the successful installation, you are ready to use the package's 44 | functionality. Simply load the package for your R session with the library 45 | call: 46 | 47 | ```{r setup, eval = FALSE} 48 | library(mapme.biodiversity) 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /man/global_surface_water_recurrence.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gsw.R 3 | \name{global_surface_water_recurrence} 4 | \alias{global_surface_water_recurrence} 5 | \alias{get_global_surface_water_recurrence} 6 | \title{Global Surface Water Recurrence} 7 | \source{ 8 | \url{https://global-surface-water.appspot.com/} 9 | } 10 | \usage{ 11 | get_global_surface_water_recurrence(version = "v1_4_2021") 12 | } 13 | \arguments{ 14 | \item{version}{A character vector indicating the version of the GSW data set 15 | to make available.} 16 | } 17 | \value{ 18 | A character of file paths. 19 | } 20 | \description{ 21 | The Global Surface Water dataset was developed by the European Commission's 22 | Joint Research Centre in the framework of the Copernicus Programme. It maps 23 | the location and temporal distribution of water surfaces at the global scale 24 | over the past 3.8 decades and provides statistics on their extent and change. 25 | It is provisioned as a global tiled raster resource available for all land 26 | areas. The reported data represent aggregated observations between 1984 - 2021. 27 | } 28 | \details{ 29 | Water Recurrence is a measurement of the degree of variability in the 30 | presence of water from year to year. It describes the frequency with which 31 | water returned to a particular location from one year to another, and is 32 | expressed as a percentage. The raster files have integer cell values between 33 | \code{[0, 100]}, where 100 represents that water reoccurs predictably every 34 | year, whereas lower values indicate that water only occurs episodically. 35 | } 36 | \references{ 37 | Pekel, JF., Cottam, A., Gorelick, N. et al. High-resolution 38 | mapping of global surface water and its long-term changes. Nature 540, 39 | 418–422 (2016). \doi{doi:10.1038/nature20584} 40 | } 41 | \keyword{resource} 42 | -------------------------------------------------------------------------------- /tests/testthat/test-get_gsw_time_series.R: -------------------------------------------------------------------------------- 1 | test_that("get_gsw_time_series works", { 2 | aoi <- read_sf( 3 | system.file("extdata", "shell_beach_protected_area_41057_B.gpkg", 4 | package = "mapme.biodiversity" 5 | ) 6 | ) 7 | 8 | .clear_resources() 9 | outdir <- file.path(tempdir(), "mapme.data") 10 | .copy_resource_dir(outdir) 11 | mapme_options(outdir = outdir, verbose = FALSE) 12 | outdir_gsw <- file.path(outdir, "gsw_time_series") 13 | 14 | gsw_fnames_short <- dir(outdir_gsw, pattern = ".tif$") 15 | gsw_fnames_long <- sub("v5_", "VER5-0_yearlyClassification", gsw_fnames_short) 16 | file.copy( 17 | file.path(outdir_gsw, gsw_fnames_short), 18 | file.path(outdir_gsw, gsw_fnames_long) 19 | ) 20 | years <- 2000:2001 21 | 22 | expect_error( 23 | get_gsw_time_series(years = years, version = ""), 24 | "version %in% available_versions is not TRUE" 25 | ) 26 | expect_error( 27 | get_gsw_time_series(years = 0), 28 | "The target years do not intersect with the availability of gsw_time_series." 29 | ) 30 | expect_warning( 31 | get_gsw_time_series(years = c(NA, NULL, ".", 2000)), 32 | "NAs introduced by coercion" 33 | ) 34 | expect_message( 35 | get_gsw_time_series(years = c(1900, 2000)), 36 | "Some target years are not available for gsw_time_series." 37 | ) 38 | expect_silent( 39 | get_gsw_time_series(years = c(2000, 2000)) 40 | ) 41 | 42 | expect_silent(.check_footprints(get_gsw_time_series(2000:2001)(aoi))) 43 | expect_silent(.check_footprints(get_gsw_time_series(2000)(aoi))) 44 | 45 | aoi_shift <- aoi 46 | gsw <- get_gsw_time_series(2000:2001) 47 | st_geometry(aoi_shift) <- st_geometry(aoi) + c(0, -90) 48 | st_crs(aoi_shift) <- 4326 49 | expect_error( 50 | gsw(aoi_shift), 51 | "The extent of the portfolio does not intersect with the GSW grid." 52 | ) 53 | }) 54 | -------------------------------------------------------------------------------- /man/gfw_lossyear.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gfw_lossyear.R 3 | \name{gfw_lossyear} 4 | \alias{gfw_lossyear} 5 | \alias{get_gfw_lossyear} 6 | \title{Year of forest loss occurrence} 7 | \source{ 8 | \url{https://data.globalforestwatch.org/documents/tree-cover-loss/explore} 9 | } 10 | \usage{ 11 | get_gfw_lossyear(version = "GFC-2024-v1.12") 12 | } 13 | \arguments{ 14 | \item{version}{The version of the dataset to download. Defaults to 15 | "GFC-2024-v1.12". Check \code{mapme.biodiversity:::.available_gfw_versions()} 16 | to get a list of available versions} 17 | } 18 | \value{ 19 | A function that returns an \code{sf} footprint object. 20 | } 21 | \description{ 22 | This resource is part of the publication by Hansen et al. (2013) 23 | "High-Resolution Global Maps of 21st-Century Forest Cover Change". It 24 | represents "Forest loss during the period 2000–2021, defined as a 25 | stand-replacement disturbance, or a change from a forest to non-forest state. 26 | Encoded as either 0 (no loss) or else a value in the range 1–20, representing 27 | loss detected primarily in the year 2001–2021, respectively." Due to changes 28 | in the satellites products used in the compilation of the tree loss product, 29 | results before the year 2011 and afterwards are not directly comparable 30 | until reprocessing has finished. Users should be aware of this limitation, 31 | especially when the timeframe of the analysis spans over the two periods 32 | delimited by the year 2011. 33 | } 34 | \references{ 35 | Hansen, M. C., P. V. Potapov, R. Moore, M. Hancher, S. A. 36 | Turubanova, A. Tyukavina, D. Thau, S. V. Stehman, S. J. Goetz, T. R. 37 | Loveland, A. Kommareddy, A. Egorov, L. Chini, C. O. Justice, and J. R. G. 38 | Townshend. 2013. “High-Resolution Global Maps of 21st-Century Forest Cover 39 | Change.” Science 342 (15 November): 850–53. 40 | } 41 | \keyword{resource} 42 | -------------------------------------------------------------------------------- /man/precipitation_chelsa.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_precipitation_chelsa.R 3 | \name{precipitation_chelsa} 4 | \alias{precipitation_chelsa} 5 | \alias{calc_precipitation_chelsa} 6 | \title{Calculate precipitation average based on CHELSA} 7 | \usage{ 8 | calc_precipitation_chelsa(years = 1979:2018, engine = "extract") 9 | } 10 | \arguments{ 11 | \item{years}{A numeric vector indicating the years for which to calculate 12 | precipitation statistics.} 13 | 14 | \item{engine}{The preferred processing functions from either one of "zonal", 15 | "extract" or "exactextract" as character.} 16 | } 17 | \value{ 18 | A function that returns an indicator tibble with variable 19 | precipitation and sum of precipitation (in mm/m^2) as value. 20 | } 21 | \description{ 22 | This functions allows to calculate averaged precipitation 23 | from the CHELSA downscaled precipitation layers. Based on 24 | user-selected years, monthly averages of precipitation are calculated. 25 | } 26 | \details{ 27 | The required resources for this indicator are: 28 | \itemize{ 29 | \item \link{chelsa} 30 | } 31 | } 32 | \examples{ 33 | \dontshow{ 34 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 35 | } 36 | \dontrun{ 37 | library(sf) 38 | library(mapme.biodiversity) 39 | 40 | outdir <- file.path(tempdir(), "mapme-data") 41 | dir.create(outdir, showWarnings = FALSE) 42 | 43 | mapme_options( 44 | outdir = outdir, 45 | verbose = FALSE 46 | ) 47 | 48 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 49 | package = "mapme.biodiversity" 50 | ) \%>\% 51 | read_sf() \%>\% 52 | get_resources(get_chelsa(years = 2010)) \%>\% 53 | calc_indicators( 54 | calc_precipitation_chelsa( 55 | years = 2010, 56 | engine = "extract" 57 | ) 58 | ) \%>\% 59 | portfolio_long() 60 | 61 | aoi 62 | } 63 | } 64 | \keyword{indicator} 65 | -------------------------------------------------------------------------------- /man/precipitation_chirps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc_precipitation_chirps.R 3 | \name{precipitation_chirps} 4 | \alias{precipitation_chirps} 5 | \alias{calc_precipitation_chirps} 6 | \title{Calculate precipitation sums based on CHIRPS} 7 | \usage{ 8 | calc_precipitation_chirps(years = 1981:2020, engine = "extract") 9 | } 10 | \arguments{ 11 | \item{years}{A numeric vector indicating the years for which to calculate 12 | precipitation statistics.} 13 | 14 | \item{engine}{The preferred processing functions from either one of "zonal", 15 | "extract" or "exactextract" as character.} 16 | } 17 | \value{ 18 | A function that returns an indicator tibble with variable 19 | precipitation and sum of precipitation (in mm) as value. 20 | } 21 | \description{ 22 | This functions allows to calculate precipitation sums based on the 23 | CHIRPS rainfall estimates. Corresponding to the time-frame of the analysis 24 | of the portfolio, monthly precipitation sums are calculated. 25 | } 26 | \details{ 27 | The required resources for this indicator are: 28 | \itemize{ 29 | \item \link{chirps} 30 | } 31 | } 32 | \examples{ 33 | \dontshow{ 34 | mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data")) 35 | } 36 | \dontrun{ 37 | library(sf) 38 | library(mapme.biodiversity) 39 | 40 | outdir <- file.path(tempdir(), "mapme-data") 41 | dir.create(outdir, showWarnings = FALSE) 42 | 43 | mapme_options( 44 | outdir = outdir, 45 | verbose = FALSE 46 | ) 47 | 48 | aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg", 49 | package = "mapme.biodiversity" 50 | ) \%>\% 51 | read_sf() \%>\% 52 | get_resources(get_chirps(years = 2010)) \%>\% 53 | calc_indicators( 54 | calc_precipitation_chirps( 55 | years = 2010, 56 | engine = "extract" 57 | ) 58 | ) \%>\% 59 | portfolio_long() 60 | 61 | aoi 62 | } 63 | } 64 | \keyword{indicator} 65 | --------------------------------------------------------------------------------