openkfw / mapme.protectedareas

Reproducible workflows in R for processing open geodata to create knowledge about KfW supported protected areas and conservation effectiveness.
GNU General Public License v3.0
3 stars 0 forks source link

Adapt matching frames to include only relevant control cells #88

Open Jo-Schie opened 2 years ago

Jo-Schie commented 2 years ago

I notice that our current matching frames include all cells irrespective if they are PAs and leakage cells. This has to be adapted asap.

Fyi @yotaae and @melvinhlwong

Jo-Schie commented 2 years ago

The following routine is suggested to be implemented in the grid creation scripts.

Output:

yotaae commented 2 years ago

Hi @Jo-Schie @melvinhlwong,

I have checked the map including treated cells from both the fishnet dataset (which includes the geom data) and the new matching frames. Specifically, I have checked the cells for the year 2007.

Quick info regarding the colors in the screenshot below:

Issue: It seems that the matching frame is missing some treated cells -> if all cells in treated PAs were included in the matching frames, the red cells would not be visible (the matching-frame-layer is above the fishnet-layer). The fishnet layer, however, seems to include the correct treated cells.

Note: Treatment in the fishnet data equals the "intersect" variable -- cells on the border are thus included.

image

yotaae commented 2 years ago

Help for debugging:

Table with number of treatment cells in the fishnet: image

Jo-Schie commented 2 years ago

First impression. There are somehow some areas, that are not part of the whole matched polygon IDs, even before creating the matching frames..

image

The reasons seems to be a problem in the intersection of the Grid with WDPA already earlier in the 01_grid_creation.R script. image

Nevertheless, this does not explain the absence of treatment cells as in yotas comment. So I guess I fix the matching frames creation first and then I will go for this initial issue of the intersection.

Jo-Schie commented 2 years ago

@yotaae

These are the cells that are now returned as treatment in 2007

image

So I can confirm, that at leat for 2007 everything is fine. Please check on your side as well for eventual bugs. Did you maybe plot the cells after matching?

Please note, that your comparison table is not really good to cover the issue, because a lot of the poly_ids in the years are somehow dupliacates. Please test again, if the problem persists.

Jo-Schie commented 2 years ago

First impression. There are somehow some areas, that are not part of the whole matched polygon IDs, even before creating the matching frames..

image

The reasons seems to be a problem in the intersection of the Grid with WDPA already earlier in the 01_grid_creation.R script. image

Nevertheless, this does not explain the absence of treatment cells as in yotas comment. So I guess I fix the matching frames creation first and then I will go for this initial issue of the intersection.

This issue seems not to persist anymore when applying the relevant filters to exclude marine areas, proposed areas, point polygons and UNESCO-MAB Biosphere Reserve.

wdpa_LA <-
  wdpa_LA %>%
  filter(DESIG_ENG != "UNESCO-MAB Biosphere Reserve") %>%
  filter(STATUS != "Proposed") %>%
  filter(GEOMETRY_TYPE != "POINT")

Hence I see this issue as resolved. See also this map, which shows the filtered areas:

image

Jo-Schie commented 2 years ago

I also checked the following years and they returned correct results: 2009, 2010, 2012, 2013 and 2016. The others I did not control because partly they have a very high number of polygons and it is not possible to render the resulting data in mapView but I see no indication why there should be problems left. Data checks are now included in the script 03_db_creation.R which allow to control the results after creating the matching frames.

Jo-Schie commented 2 years ago

I created now the routine to only include leakage zones for the respective years. The results look like this (example year 2011, snippet is from Colombia I guess)

image

image

After reimport and a check on your side @yotaae, we can close this issue.