prioritizr / wdpar

Interface to the World Database on Protected Areas
https://prioritizr.github.io/wdpar
GNU General Public License v3.0
37 stars 5 forks source link

erase_overlaps problem: many areas are not erased #73

Closed Va99le closed 11 months ago

Va99le commented 11 months ago

Hi Jeffrey, I'm sorry to bother you again. I' m having some trouble with "wdpa_clean", particularly with erase overlaps. I am performing a fine scale analysis on a european level, so precision matters. After performing the cleaning procedures on multiple countries, and checking them against the "dissolved" version of the PA of same state ("wdpa_dissolve", used after that in "wdpa_clean" erase_overlaps= FALSE), I realized that many area were not erased, since there is a significant differences in the area between the dissolved state and the erased one. The values are significantly higher for the erased one. Checking the files on Qgis, i realized there were many overlapping parts, like the one in the pictures (which is only provided as an example): image image image As in the picture, the Pilat area is a bigger area, with a defined IUCN category of protection (V), while the smaller area Crts du Pilat, located inside the previus one, has no IUCN category (not reported). Also, the pilat area was designed well before the Crts du Pilat (1974 vs 2014), so it should have been erased. The same is true for many other areas.

For example, in Italy the dissolved area is about 69 561 Km^2 (after performing st_intersection() with Italy's border as provided by the Global Administrative Areas dataset), while his area after the erase_overlaps is of 76 354 km^2.

Is there something I can do to fix the problem? Is there something I 'm getting wrong?

Thank you

jeffreyhanson commented 11 months ago

Hi,

Sorry the for the late reply @Va99le! Wow, yeah, that's definitely not correct. Thank you very much for reporting this. I'll take a look at this and see what I can do.

jeffreyhanson commented 11 months ago

I think I've found a fix - can you please try running it again with the fix-73 branch? If it works, I'll merge into the main branch. To install the branch, please use this code:

remotes::install_github('prioritizr/wdpar@fix-73')
Va99le commented 11 months ago

It worked! Thank you very much! Now the area of the erased file is the same as the dissolved one. Thank you again for your time and work

jeffreyhanson commented 11 months ago

Awesome! Just to check, since your first message indicated that the update didn't work - was there any installation issues or changes to your cleaning code that needed to be fixed to get it to work?

Va99le commented 11 months ago

I made a mistake in the code: I recalled the packages and after that I run the fix line, and then the cleaning code. I should have recalled the packages after the installation of the fix. I didn't realize at first!

jeffreyhanson commented 11 months ago

Ah ok - thanks for clarifying that. I'll merge the PR and then prepare an update to get the fix on CRAN. Thanks again for reporting this issue!