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

Error when running wdpa_fetch() #69

Closed Aisling-Wang closed 1 year ago

Aisling-Wang commented 1 year ago

I am using version 4.3.1.

When I called lie_raw_data <- wdpa_fetch("Liechtenstein", wait = TRUE), I got the following error: Error in session_makeRequest(self, private, endpoint, data, params, headers) : Unable to find element with css selector '.download__trigger'

I am not familiar with css selector, so I don't know how to fix the problem. Anyone can help me? Thanks a lot.

fBedecarrats commented 1 year ago

Hello, same problem here. Does it correspond to a modification from the source portal?

jeffreyhanson commented 1 year ago

Hi,

Thank you very much for reporting this issue. I'm currently travelling so it might be a while before I can get to this. I'll see if I can find time later tonight - but no promises. In the mean time, you might be able to hopefully download the WDPA data manually and import the data from the zip file using wdpa_read() -- as long as Protected Planet hasn't updated the zip file format too.

jeffreyhanson commented 1 year ago

I'm having trouble accessing some parts of the protected planet website using a web browser. For example, when I try viewing the web page for the protected areas of Australia (i.e., https://protectedplanet.net/en/country/AUS), I see the error below.

image

So, my guess is that there's some issue with protected planet and this, in turn, is causing an issue for wdpar. So hopefullly, once protected planet fix the website, this will resolve the issue for wdpar? If anyone has any other ideas, I'd be happy to explore them? But it seems like we might have to wait for protected planet to fix things on their end.

Aisling-Wang commented 1 year ago

Hi, Jeffrey. I can manually download the data of Australia on https://www.protectedplanet.net/country/AUS, but it is only the latest month. Now I want to download the global data for December 2019, but I don't know how to operate it.

fBedecarrats commented 1 year ago

Hi, Jeffrey. I can manually download the data of Australia on https://www.protectedplanet.net/country/AUS, but it is only the latest month. Now I want to download the global data for December 2019, but I don't know how to operate it.

Hi @Aisling-Wang, this question is not related to the wdpar package and you should ask it to the UNEP-WCMC peopole who produce the WDPA data. Anyway, you can download the data you are looking for here: https://pp-import-production.s3-eu-west-1.amazonaws.com/WDPA_Dec2019_Public.zip

Aisling-Wang commented 1 year ago

Thanks

Hi, Jeffrey. I can manually download the data of Australia on https://www.protectedplanet.net/country/AUS, but it is only the latest month. Now I want to download the global data for December 2019, but I don't know how to operate it.

Hi @Aisling-Wang, this question is not related to the wdpar package and you should ask it to the UNEP-WCMC peopole who produce the WDPA data. Anyway, you can download the data you are looking for here: https://pp-import-production.s3-eu-west-1.amazonaws.com/WDPA_Dec2019_Public.zip

Thanks.

jeffreyhanson commented 1 year ago

Just to give an update, I think I've found a fix to this problem. I'll try and push a branch with the fix later today so you can see if it works on your computers?

fBedecarrats commented 1 year ago

Hi, thanks!!! I'll need a couple of days to test. I'm currently traveling.

jeffreyhanson commented 1 year ago

I think I've got it working now, could you please try installing the fixes branch and see if it works for you? This can be done using the following code:

remotes::install_github("prioritizr/wdpar@fixes")
jeffreyhanson commented 1 year ago

Hi @fBedecarrats and @Aisling-Wang, I just wanted to follow up and see if the updates in the fixes branch have fixed the wdpa_fetch() function for you?

fBedecarrats commented 1 year ago

Hi @jeffreyhanson, sorry for the delay. I'm still doing field work ik Senegal. I hope to be able to do it tomorrow.

jeffreyhanson commented 1 year ago

No worries @fBedecarrats! Thanks so much for the quick repsonse. I just wanted to make sure my previous message didn't get lost. Hope the field work goes well!

fBedecarrats commented 1 year ago

Hi @jeffreyhanson, Just did the tests and it seems that the fixes work. But what is most weird is that the CRAN version also works now:

# Use CRAN version
install.packages("wdpar")
library(wdpar)
webdriver::install_phantomjs()

lie_raw_data <- wdpa_fetch("Liechtenstein", wait = TRUE)
# [100%] Downloaded 11466840 bytes...
nrow(lie_raw_data)
# [1] 45

# Test fix branch
detach("package:wdpar", unload = TRUE)
remove.packages("wdpar")
remotes::install_github("prioritizr/wdpar@fixes")
library(wdpar)
lie_raw_data <- wdpa_fetch("Liechtenstein", wait = TRUE)
# no download progress message
nrow(lie_raw_data)
# [1] 45
jeffreyhanson commented 1 year ago

Brilliant - thanks so much @fBedecarrats!

Yeah, I dunno why the CRAN version is working again. I originally thought the issue with the downloading errors was due to issues with the protected planet website - so maybe they've fixed them now? I dunno. I'll merge the changes in the fix branch, since they seem to be more robust to issues with the protected planet website.