Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge BII to main #192

Merged
merged 18 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
302 changes: 302 additions & 0 deletions pipelines/BII/BII.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
{
"nodes": [
{
"id": "9",
"type": "io",
"position": {
"x": 284,
"y": 110
},
"data": {
"descriptionFile": "data>getBoundingBox.yml"
}
},
{
"id": "15",
"type": "io",
"position": {
"x": 756,
"y": 190
},
"data": {
"descriptionFile": "BII>BIIZonalStats.yml"
}
},
{
"id": "16",
"type": "output",
"position": {
"x": 1308,
"y": 258.5
},
"data": {
"label": "Output"
}
},
{
"id": "17",
"type": "output",
"position": {
"x": 1308,
"y": 307.5
},
"data": {
"label": "Output"
}
},
{
"id": "18",
"type": "output",
"position": {
"x": 1308,
"y": 209.5
},
"data": {
"label": "Output"
}
},
{
"id": "19",
"type": "io",
"position": {
"x": 1308,
"y": 119.5
},
"data": {
"descriptionFile": "BII>BIIChange.yml"
}
},
{
"id": "20",
"type": "output",
"position": {
"x": 1869,
"y": 180
},
"data": {
"label": "Output"
}
},
{
"id": "22",
"type": "userInput",
"position": {
"x": 12,
"y": 23.166666666666664
},
"dragHandle": ".dragHandle",
"data": {
"type": "text"
}
},
{
"id": "23",
"type": "userInput",
"position": {
"x": 13,
"y": 78.16666666666666
},
"dragHandle": ".dragHandle",
"data": {
"type": "text"
}
},
{
"id": "24",
"type": "output",
"position": {
"x": 284,
"y": 12
},
"data": {
"label": "Output"
}
}
],
"edges": [
{
"source": "9",
"sourceHandle": "bbox",
"target": "15",
"targetHandle": "bbox",
"id": "reactflow__edge-9bbox-15bbox"
},
{
"source": "9",
"sourceHandle": "study_area_polygon",
"target": "15",
"targetHandle": "study_area_polygon",
"id": "reactflow__edge-9study_area_polygon-15study_area_polygon"
},
{
"source": "15",
"sourceHandle": "ts_plot",
"target": "16",
"targetHandle": null,
"id": "reactflow__edge-15ts_plot-16"
},
{
"source": "15",
"sourceHandle": "stats",
"target": "17",
"targetHandle": null,
"id": "reactflow__edge-15stats-17"
},
{
"source": "15",
"sourceHandle": "rasters",
"target": "18",
"targetHandle": null,
"id": "reactflow__edge-15rasters-18"
},
{
"source": "15",
"sourceHandle": "rasters",
"target": "19",
"targetHandle": "rasters",
"id": "reactflow__edge-15rasters-19rasters"
},
{
"source": "19",
"sourceHandle": "bii_change",
"target": "20",
"targetHandle": null,
"id": "reactflow__edge-19bii_change-20"
},
{
"source": "22",
"sourceHandle": null,
"target": "9",
"targetHandle": "country",
"id": "reactflow__edge-22-9country"
},
{
"source": "23",
"sourceHandle": null,
"target": "9",
"targetHandle": "state",
"id": "reactflow__edge-23-9state"
},
{
"source": "22",
"sourceHandle": null,
"target": "24",
"targetHandle": null,
"id": "reactflow__edge-22-24"
}
],
"inputs": {
"data>getBoundingBox.yml@9|study_area_file": {
"description": "Upload a file of a custom study area",
"label": "File for study area",
"type": "text",
"weight": 0,
"example": null
},
"BII>BIIZonalStats.yml@15|summary_statistic": {
"description": "Summary statistic for layers",
"label": "Summary statistic",
"type": "options",
"options": [
"Mean",
"Median",
"Mode"
],
"example": "Mean",
"weight": 1
},
"BII>BIIChange.yml@19|start_year": {
"description": "Reference BII year for raster plotting",
"label": "Start year for BII raster comparison",
"type": "options",
"options": [
"2000",
"2005",
"2010",
"2015"
],
"example": "2000",
"weight": 2
},
"BII>BIIChange.yml@19|end_year": {
"description": "BII layer to compare to the start year",
"label": "End year for BII comparison",
"type": "options",
"options": [
"2005",
"2010",
"2015",
"2020"
],
"example": "2020",
"weight": 3
},
"pipeline@22": {
"label": "Country",
"description": "Country of interest",
"type": "text",
"example": null,
"weight": 4
},
"pipeline@23": {
"label": "State/Province",
"description": "State or province of interest (leave blank if you want the full country)",
"type": "text",
"example": null,
"weight": 5
}
},
"outputs": {
"pipeline@22|default_output": {
"description": "Country of interest",
"label": "Country",
"type": "text",
"weight": 0
},
"BII>BIIZonalStats.yml@15|stats": {
"description": "Summary statistic",
"label": "Statistical measure",
"type": "text/csv",
"weight": 1
},
"BII>BIIZonalStats.yml@15|rasters": {
"description": "Array of output raster paths",
"label": "BII layers for each year",
"type": "image/tiff;application=geotiff[]",
"weight": 2
},
"BII>BIIZonalStats.yml@15|ts_plot": {
"description": "Time series plot of BII values in zone of interest",
"label": "Time series plot",
"type": "image/png",
"weight": 3
},
"BII>BIIChange.yml@19|bii_change": {
"description": "Raster plot of change in BII",
"label": "Change in BII",
"type": "image/tiff;application=geotiff[]",
"weight": 4
}
},
"metadata": {
"name": "Biodiversity Intactness Index",
"description": "This pipeline calculates zonal statistics of the biodiversity intactness index of a given country or region and change over time using the BII layers developed by the Natural History Museum.",
"author": [
{
"name": "Jory Griffith",
"email": "jory.griffith@mcgill.ca"
}
],
"license": "CC-BY-NC-SA",
"references": [
{
"text": "De Palma et al. 2024",
"doi": "https://doi.org/10.5519/k33reyb6"
},
{
"text": "Newbold et al. 2016",
"doi": "https://doi.org/10.1126/science.aaf2201"
}
]
}
}
26 changes: 26 additions & 0 deletions pipelines/BII/BII.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
The Biodiversity Intactness Index (BII) is a metric designed to assess the degree to which ecosystems are intact and functioning relative to their natural state. It measures the abundance and diversity of species in a given area compared to what would be expected in an undisturbed ecosystem. The BII accounts for various factors, including habitat loss, fragmentation, and degradation, providing a comprehensive view of biodiversity health. A higher BII value indicates a more intact ecosystem with greater species diversity and abundance, while a lower value suggests significant ecological disruption. The biodiversity intactness index is a complimentary indicator in the GBF.

**Methods:**
The BII is created by the Natural History Museum and uses their PREDICTS database, which aggregates data from studies comparing terrestrial biodiversity at sites experiencing varying levels of human pressure. It currently contains over 3 million records from more than 26,000 sites across 94 countries, representing a diverse array of over 45,000 plant, invertebrate, and vertebrate species. The BII uses the PREDICTS database to establish a reference state using the biodiversity patterns in habitats with minimal disturbance levels. Then, it assigns sensitivity scores to each species based on their vulnerability to human pressure. Intactness is calculated by comparing the observed species abundance in a given area to what is expected under reference conditions with low human impact.

**The BON in a Box pipeline:**
The Natural History Museum has created raster layers of BII since the year 2000. BON in a Box has a pipeline to calculate summary statistics and plot a time series from these layers in a country, region, or custom study area of interest. The pipeline has the following inputs:
* **Country:** The user can input a country of interest for which they want to calculate BII summary statistics.
* **Region:** The user can specify a state or province of interest for which they want to caluculate BII summary statistics.
* **File for study area:** The user can upload a custom study area file as a polygon instead of specifying a country or region.
* **Summary statistic:** The user can choose the summary statistic for BII (options: mean, median, mode) that will be calculated for the country or region of interest.
* **Start and end year for BII raster comparison:** The user can specify two years for which they want to compare BII. The pipeline will create a raster layer of BII change.

The pipeline has the following outputs:
* **Time series plot:** A time series plot of the chosen summary statistic over years for the country or region of interest.
* **Summary statistic:** A table of the summary statistic values of BII over years. This can be downloaded as a CSV file.
* **Rasters:** The user can view all of the raster layers for each year that were used to generate the summary statistics.
* **Change in BII:** A raster plot of the change in BII between the two chosen years.

**Contributors:**
* Jory Griffith (https://orcid.org/0000-0001-6020-6690)

**Citations:**
Adriana De Palma; Sara Contu; Gareth E Thomas; Connor Duffin; Sabine Nix; Andy Purvis (2024). The Biodiversity Intactness Index developed by The Natural History Museum, London, v2.1.1 (Open Access, Limited Release) [Data set]. Natural History Museum. https://doi.org/10.5519/k33reyb6

Newbold, T., Hudson, L. N., Arnell, A. P., Contu, S., De Palma, A., Ferrier, S., Hill, S. L. L., Hoskins, A. J., Lysenko, I., Phillips, H. R. P., Burton, V. J., Chng, C. W. T., Emerson, S., Gao, D., Pask-Hale, G., Hutton, J., Jung, M., Sanchez-Ortiz, K., Simmons, B. I., … Purvis, A. (2016). Has land use pushed terrestrial biodiversity beyond the planetary boundary? A global assessment. Science, 353(6296), 288–291. https://doi.org/10.1126/science.aaf2201
34 changes: 34 additions & 0 deletions scripts/BII/BIIChange.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is to look at change in BII over time
library("rjson")
library("terra")
library("dplyr")

source(paste(Sys.getenv("SCRIPT_LOCATION"), "/data/loadFromStacFun.R", sep = "/"))

input <- fromJSON(file=file.path(outputFolder, "input.json"))

output<- tryCatch({

start_yr <- paste0("bii_nhm_10km_", input$start_year)
end_yr <- paste0("bii_nhm_10km_", input$end_year)

# Load rasters as a raster stack
rasters <- terra::rast(c(input$rasters))
print(names(rasters))

first_raster <- rasters[[names(rasters)==start_yr]]
end_raster <- rasters[[names(rasters)==end_yr]]

print(names(first_raster))
# Summarise
bii_change <- first_raster-end_raster

# Output
bii_change_path <- file.path(outputFolder, "BII_change.tif")
writeRaster(bii_change, bii_change_path)

output <- list("bii_change"=bii_change_path)
}, error = function(e) { list(error = conditionMessage(e)) })

jsonData <- toJSON(output, indent=2)
write(jsonData, file.path(outputFolder,"output.json"))
Loading
Loading