I used an AOI at the ADM1 level with the following code, but I couldn’t get the correct proportion of photo user days (pr_PUD[i]).
I want to calculate the proportion for each province as
# The proportion in each cell i
pr_PUD[i] = PUD_YR_AVG[i] / PUD_YR_AVG.sum()
pr_TUD[i] = TUD_YR_AVG[i] / TUD_YR_AVG.sum()
avg_pr_UD[i] = (pr_PUD[i] + pr_TUD[i]) / 2
*This equation is from "User Days" of Visitation: Recreation and Tourism on your InVEST guideline.
where the sum is taken at the ADM1 level. However, I’m not getting the correct PUD proportion because it seems that all avg_pr_UD[i] of each province equals 1 when I run the code for each province individually. How can I correctly compute the PUD proportion for each province at the ADM1 level?
Should I calculate it manually? or Should I change the AOI to cell level? or Is there other ways?
I think I understand your question, but please correct me if I’m misinterpreting.
it seems that all avg_pr_UD[i] of each province equals 1 when I run the code for each province individually
This is what’s expected when each province is its own AOI. The sum is over all cells/polygons in the AOI in the run. If your AOI is just 1 polygon (1 province, not gridded), then the sum will equal the average. If your AOI is gridded but you run the model province by province, then for each loop, PUD_YR_AVG.sum() is the sum over cells in that province only. So, within each province, the pr_PUD and therefore avg_pr_UD will sum to 1.
If I understand your goal correctly, you want each province’s pr_PUD to reflect its share of the whole study area, so that the sum across all province of pr_PUD = 1. To achieve this, you can build a single AOI vector that contains all provinces as their own features, and then don’t split by province in a loop (i.e., just run the model once and set grid_aoi=False so that the polygons in the AOI are the provinces). You will then see in the resulting regression data gpkg, a row per province that contains attribute pr_PUD which gives “the proportion of the sum of PUD_YR_AVG across all features” which is calculated as PUD_YR_AVG for the feature divided by the PUD sum of all features. Here is the User’s Guide section about how to interpret the results (including for regression_data.gpkg): Visitation: Recreation and Tourism — InVEST® documentation
I divided the AOI by province because I couldn’t successfully run the entire country AOI due to limitations on the number of points required for the recreation model.
Therefore, I think I cannot get the desired output when I put the single AOI vector that contains all provinces…