Comments (10)
Hi @fabeit,
Thanks for reaching out! Just to check, when you're dissolving the global dataset by country, are you using wdpa_dissolve()
? If so, I would suggest to try increasing geometry_precision
and see if that fixes it (e.g., you might need to try some really high values for it to work)?
from wdpar.
Thanks for the quick reply. Yes I am using that function and it stalls or gives errors. I can try with a larger value but how do I dissolve per country?
from wdpar.
Yeah, you could do something like this (see below). The code assumes that x
is your cleaned version of the data, and the column COUNTRY
has the country name for each protected area. I haven't tested this, so it might need some debugging.
# load packages
library(wdpar)
library(sf)
library(dplyr)
# dissolve by country
result <-
x %>%
split(.$COUNTRY) %>%
lapply(function(y) {
n <- y$COUNTRY[[1]]
y <- wdpa_dissolve(y)
y$COUNTRY <- n
y
}) %>%
bind_rows()
from wdpar.
Thank you for the suggestion Jeffrey. Unfortunately I run into the same error that I get when I tried to dissolve the global data set such as
Error in wk_handle.wk_wkb(wkb, s2_geography_writer(oriented = oriented, :
Loop 2 is not valid: Edge 2 crosses edge 4y, I also tried geometry_precision = 1500000000 and I get
Error in wk_handle.wk_wkb(wkb, s2_geography_writer(oriented = oriented, :
Loop 0 edge 314 crosses loop 5 edge 24
There seems no way to do this in a reasonable way, the MPA data is too messy. It's quite frustrating.
from wdpar.
Hmm, do you know which country is causing the error?
Also, you could try repairing the geometries again before dissolving it. E.g., something like this:
# load packages
library(wdpar)
library(sf)
library(dplyr)
# dissolve by country
result <-
x %>%
split(.$COUNTRY) %>%
lapply(function(y) {
n <- y$COUNTRY[[1]]
print(paste("starting", n))
y <- sf::st_set_precision(y, 1e5)
y <- sf::st_make_valid(y)
y <- wdpa_dissolve(y)
y$COUNTRY <- n
y
}) %>%
bind_rows()
Also, if you have access to ArcGIS, you cold try using the repair geometry tool and then the dissolve tool? IME ArcGIS is better at handling these geometry issues.
from wdpar.
That's a good idea to debugging the problem. It seems that it gets stuck at Australia. I will have to try to exclude it but I doubt that it will go smoothly for all other countries, especially the ones that have complex geometries.
Unfortunately I don't have access to ArcGIS. I'm surprised that there's no publicly accessible this dissolved shape file of all MPAs.
from wdpar.
Hmm, could you try increasing the precision in the above coded to something super high like 1e10
?
Also, just to check, are you using the latest version of the sf and lwgeom packages?
Yeah, the license for the WDPA prohibits redistributing the database and any derived datasets (see https://www.protectedplanet.net/en/legal), which means people can't directly share any cleaned up or pre-processed versions of the dataset.
from wdpar.
Just to follow up @fabeit, were you able to resolve this issue? Anything I can do to help?
from wdpar.
I was never able to resolve the issue. I ended up asking UNEP to send me a shapefile with dissolved polygons for each country. I think something like this should be made public.
from wdpar.
Ah - sorry, I wasn't able to help with resolving it. Glad to hear that you got the data you needed in the end.
from wdpar.
Related Issues (20)
- It takes forever to eraseoverlap for global dataset. HOT 22
- wdpa_fetch HOT 6
- I used the newest version of wdpar, still have this "side location conflict" HOT 7
- The package not run for previous download data, and do not start a new download data HOT 6
- GEOS version sensitivity HOT 7
- upcoming sf breaks wdpar HOT 6
- JOSS Review: Improve documentation on geo-processing steps and its effects on the original geometries HOT 12
- JOSS Review: Improve Statement of need / description of use-cases HOT 16
- JOSS Review - Add links to references cited in README HOT 3
- JOSS Review warning about out of date local data HOT 6
- JOSS Review: Add small POC about Performance claims HOT 7
- JOSS Review: Add statement about state of the field HOT 4
- wdpa_fetch() no longer works HOT 4
- Erase overlaps keeps failing HOT 19
- Error when running wdpa_fetch() HOT 14
- package overview manual entry
- erase_overlaps problem: many areas are not erased HOT 6
- Error with wdpa_fetch() HOT 2
- Error downloading "global" data with wdpa_fetch HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wdpar.