Closed GatesDupont closed 4 years ago
Hi,
I'm very sorry for the slow response. I've been on vacation and then attending a conference, so I haven't had a chance to respond to you earlier. It looks like the wdpar is having problems with the geometry of the data. Broadly speaking, R's ability to clean invalid geometry is generally pretty good (and by this I specifically mean the lwgeom package), but it can fail to clean really invalid geometries. Unfortunately, there isn't much I can do about this.
I would recommend: (i) manually saving the data to a shapefile (see sf::st_write
), (ii) fixing it ESRI ArcMap using the repair geometry tool, and (iii) then importing the fixed data into R and running the wdpa_clean
function again. I'm sorry I don't have a better solution that doesn't involve commercial software.
Cheers,
Jeff
Hello,
I ran into the same problem (see also #16 ) and solved it by changing in st_erase_overlaps
this line:
u <- sf::st_union(sf::st_set_precision(sf::st_buffer(o[ovr], 0), precision))
to
u <- sf::st_buffer(sf::st_union(sf::st_set_precision(sf::st_buffer(o[ovr], 0), precision)),dist = 0)
Awesome work @antoinestevens! Thank you so much for coming up with a fix! I'll patch that into the dev version of the wdpar package now.
Actually, it essentially fixed #16 but not this issue.
Modifying 2 lines below (don't ask me why) with st_make_valid
will finally fix all my problems
d <- sf::st_difference(sf::st_set_precision(g[i],precision), lwgeom::st_make_valid(sf::st_set_precision(u, precision)))
Thank YOU for your awesome work (inc. your other super useful packages)
Ok brilliant - I'll patch that fix in as well - thanks again!
Thank you - I really appreciate it.
I forgot to tag this issue in the latest commit, so I'll close this manually now.
I'm trying to download and clean the wdpa data for Brazil, and have run into an error.
I start by downloading the data, which works, but I get an error just about halfway through cleaning it.
Here's the result, note the error on the bottom:
I get a similar issue with Mexico, as well.
Any help with this would be greatly appreciated!
Thanks!