Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class error in wdpa_clean #19

Closed
JonasGeschke opened this issue Feb 18, 2020 · 13 comments
Closed

class error in wdpa_clean #19

JonasGeschke opened this issue Feb 18, 2020 · 13 comments
Assignees

Comments

@JonasGeschke
Copy link

JonasGeschke commented Feb 18, 2020

After trying around with the sp package for quite a bit, I will now try to flatten the WDPA with wdpar. The first error I came across, however, is as follows:

Error in st_cast_sfc_default(x) : list item(s) not of class sfg

It came in the WDPA subset for "SOM" (Somalia). Would be great if you can have a look at it.
Thanks and best regards,
Jonas

@JonasGeschke
Copy link
Author

JonasGeschke commented Feb 18, 2020

Are you @jeffreyhanson around at the sri2020.org conference? Would be great meeting you.

@jeffreyhanson
Copy link
Collaborator

Hmm - that's strange. Could you please post a reproducible example showing this? Are you using as(x, "sf") to convert the sp class objects to sf class objects before using wdpa_clean?

No, I'm not attending that conference unfortunately - it looks pretty interesting! Yeah - it would be great to catch up. I'm based in Palmerston North in New Zealand - I don't suppose you're travelling to New Zealand while you're in the region?

@jeffreyhanson jeffreyhanson self-assigned this Feb 18, 2020
@JonasGeschke
Copy link
Author

Well no I didnt convert the WDPA from sp to sf, I read the WDPA with wdpar:

wdpa <- wdpa_read("~/WDPA_Feb2020-shapefile.zip")
wdpa <- wdpa[-which(wdpa$MARINE == "2"),]
wdpa <- wdpa[-which(wdpa$ISO3 == "ABNJ"),]
wdpa_som <- wdpa[which(wdpa$ISO3 == "SOM"),]
wdpa_som <- wdpa_clean(wdpa_som)

Bildschirmfoto 2020-02-19 um 10 30 41

(sorry it is in German, but the error remains the same)

@JonasGeschke
Copy link
Author

update: I now tried to clean SOM with the development version of wdpar – it worked. so in case you dont want to follow up on the origin of the error, you may close the issue.

@JonasGeschke
Copy link
Author

JonasGeschke commented Feb 21, 2020

its your go to close it in case you are good to go ;-)

@jeffreyhanson
Copy link
Collaborator

Great - glad to hear it's working. I'll close this issue now then. In the future, if you feel that you've solved an issue that you've opened, please feel free to close it yourself :)

@JonasGeschke
Copy link
Author

Strange... with a changed precision, the error comes up again. Would be great if you could have a look at it.

Error in st_cast_sfc_default(x) : list item(s) not of class sfg

@JonasGeschke
Copy link
Author

So this class error still is the bottleneck in my progress...

@jeffreyhanson
Copy link
Collaborator

Per #22, could you please post a complete reproducible example showing the issue you're experiencing?

@jeffreyhanson jeffreyhanson reopened this Mar 2, 2020
@JonasGeschke
Copy link
Author

Hi – sorry for not replying yet. You can find the reproducible example above. However, it does not pop up always, I have no clue why. Did you change anything in the development version that could have lead to fixing the class error?

@JonasGeschke
Copy link
Author

Congrats to your paper, very nice reading!

In regard of my work on the WPDA, using wdpar: I am in still in progress cleaning and unioning all countries individually and plan to union them together afterwards.
During the computing, the class error came up again – using the development version of the package. Would be great if you find some time working on this error.

@jeffreyhanson
Copy link
Collaborator

Thanks! It looks like the issue with Somalia is that all the protected areas are points and they have a REP_AREA of zero - meaning that there are no "spatially valid non-empty" geometries for this country. I'll add in a patch to return an empty result (i.e. sf object with zero rows) for such cases.

@jeffreyhanson
Copy link
Collaborator

jeffreyhanson commented Mar 28, 2020

Ok - I've just pushed a new version to GitHub that works for Somalia. Thanks for the reminder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants