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…
That makes sense and apologies, I didn’t give you the best advice before. To clarify: are you trying to get the proportion of user-days attributable to polygon/cell i?
If so, you should be able to get national-level proportions without using the whole country as the AOI. Because you’re forced to split by province, and the normalization happens separately per province, you just need to re-do that normalization yourself with a national denominator (and ignore the pre-calculated pr_*). You can use the PUD_YR_AVG and TUD_YR_AVG, which are average annual user-days and are not normalized by province. Then, (assuming the provinces are not overlapping) you should be able to manually recompute the proportions by summing all provinces.
If you want the specific steps of what that looks like:
For each province run, grab PUD_YR_AVG and TUD_YR_AVG
Collect all these results together and add them all up to get the total PUD_YR_AVG and TUD_YR_AVG for the whole country
For each province, compute its share of the entire country’s PUD and TUD by dividing its PUD_YR_AVG and TUD_YR_AVG the total sum
Then you can average the 2 proportions to get the national level recreation proportion for each province
I understand now, and I’ll calculate those proportions manually. However, I was considering using the proportion of user-days as an input for the regression within the Recreation model. If I compute the proportion of user-days for each province, does that mean I’ll also need to run the regression manually?
If I’m misunderstanding this, please let me know.
Thanks in advance for your quick response!
Yes, I think you’ll have to run the regression manually as InVEST runs the regression on whatever AOI you give it and therefore the regression coefficients you get would be specific to the province.