Dear all
We have adapted the InVEST pollination model python script to make the species input spatially explicit: Instead of one guild table (the same relative abundance of wild-bee species for all grid points in Switzerland) we are using bioclimatic species maps (probability of occurrence 0-100%). So every grid point has its own relative abundance of wild-bee species. However after changing formula 59 the model should work exactly the same as the standard, as every grid point has its single input value for relative abundance. Furthermore Eric Lonsdorf also confirmed that InVEST is automatically standaredising input values for relative abundance to 0-1. I had a short chat with Eric Lonsdorf and he suggested to contact the software team. We have some unexpected results that the output (supply, abundance, total and for each species) are far over 1.
Is there somebody to contact directly providing some support the python code?
Kind regards
Sibylle
@jdouglass @dave @swolny @mlacayo @jesseG
Hi @sibylles,
This is great that you’ve been adapting the pollination model to incorporate spatially explicit data.
I would first recommend confirming that your species maps are being properly normalized to 0-1 before being passed into the model. Or, could you try manually normalizing your species maps and see if you still get the same results?
If you can confirm this, I have a few follow-up questions: How are you normalizing the relative abundance raster? What are the unexpected values you are getting? Would you be willing to share your data (an example of your spatially explicit file that you’ve created and the unexpected results you’re getting)? Are you working on this model in a repo that you can share?
Thanks
Hi @csimpson
Many thanks for you reply.
Yes I can conform that I have normalized now my species maps
Values between 0-1. I normalized them by the total of all the pixels, do you have any other suggestion?
Here the R code
library(raster)
input_directory ← “O:/Data…” # Pfad anpassen
output_directory ← “O:…” # Pfad für normalisierte Raster
dir.create(output_directory, showWarnings = FALSE) # Sicherstellen, dass das Output-Verzeichnis existiert
normalize_raster ← function(input_path, output_path) {
raster ← raster(input_path) # Raster einlesen
normalized_raster ← raster / 100 # Normalisieren (0–100 → 0–1)
writeRaster(normalized_raster, output_path, overwrite = TRUE)
}
files ← list.files(input_directory, pattern = “\.tif$”, full.names = TRUE)
for (file in files) {
output_file ← file.path(output_directory, basename(file)) # Behalte den Dateinamen bei
cat(“Normalisiere:”, file, “->”, output_file, “\n”)
normalize_raster(file, output_file)
}
Find here the official code. We realised that the python code is normalising guild table data, but not our raster data. So that it why I normalized our raster data manually:
In the code for the official version 3.14.2 pollination model, starting on line 1332, the species abundance in the guild table is divided by the total species abundance.
Here our adapted code:
I am wondering if there is an easy way to normalize the raster data as built-in function similar to the guild tables?
NCCS-InVEST/README.rst at main · mlacayoemery/NCCS-InVEST
Kind regards
Sibylle
@Lisa
Hi @sibylles
Find here the official code.
Here our adapted code:
I’m not sure if you’ve tried to insert a hyperlink to your code in either of the above spots but if so, I’m unable to see it.
I am wondering if there is an easy way to normalize the raster data as built-in function similar to the guild tables?
The InVEST Pollination model does not support spatially explicit species inputs at this time, so I think your best option is to make custom adjustments required for your data, as the pollination model does not currently have built-in functionality for this. That’s great that you’ve taken a look at the source code and I would definitely recommend looking at this to ensure that you follow the way the model treats the relative species abundance in the guild table. As you mentioned, the species abundance is divided by total species abundance, so (assuming I understand your data correctly) you should be calculating total species abundance by pixel by summing your species relative abundance rasters and dividing each of your species maps by that total abundance raster.
Hope this helps!
The adapted code using hypterlink:
https://github.com/mlacayoemery/NCCS-InVEST
Normalization
- Yes the normalization is done for each species (map) separately.
- No my absolute values are probaility of species occurence from species distribution data (0-100%) that are normalized. So it sums probability data and calculated for each raster of the total sum. Does this make sense?
- Maybe I should provide the code to the R-help to have a cross-check.
Kind regards
Sibylle
sorry: it calculates for each raster the percentage of the total sum.