prioritizr / wdpar

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

No internet connection with R Studio to download wdpa data? #10

Closed ankemueller closed 2 years ago

ankemueller commented 5 years ago

Dear Jeff, I was excited to try out your wdpar package and downloaded it yesterday. When I tried to let your example run I received the following error:

mlt_raw_pa_data <- wdpa_fetch("MLT", wait = TRUE)

Error in wdpa_fetch("MLT", wait = TRUE) : data not found in download_dir, and no internet connectionto download it.

As far as I understood your description, WDPA data should be downloaded by your package automatically, so no need for me to manually put something in the download-dir, right? I do not understand why I get the "no internet connection" error as I am connected to the internet and downloading packages from CRAN works just fine. I use R Studio Version 1.1.463 and R Version 3.5.2. Maybe you have an idea why it is not working for me?

Anyway, thanks for providing this cool package! Cheers, Anke

jeffreyhanson commented 5 years ago

Hi,

Yeah, you should be able to download the data automatically with wdpa_fetch. This package uses the pingr::is_online function to detect if you have an internet connection. Could you please try running pingr::is_online() to see if its working correctly?

Cheers,

Jeff

jeffreyhanson commented 5 years ago

I'm closing this due to inactivity, but please feel free to open this if you want to help solve the issue.

neriiacopo commented 5 years ago

Hi Jeff, I am experiencing the same issue as Anke. While running wdpa_fetch() on a window machine I get the same error. As you suggested, I tried pingr::is_online() where I look incorrectly without an internet connection. The https://cran.r-project.org is inaccessible at the moment (I guess they are having server issues). I am wondering if this is the reason behind the error and if there is a way to overcome it...

update: I am now able to access https://cran.r-project.org from my browser but still pingr::is_online return a FALSE statement. I have been trying curl::has_internet() , nslookup() , and the method showed in https://stackoverflow.com/questions/7012796/ping-a-website-in-r and they all return positive statement. Maybe you have an idea what I am missing?

Looking forward to use Wdpar thank you so much for you help

Iacopo

jeffreyhanson commented 5 years ago

Hi, I don't think this is related to the CRAN issues. I have an idea for fixing this though, so I'll push a new version to GitHub later today and we can see if this fixes the problem.

jeffreyhanson commented 5 years ago

Actually, if curl::has_internet works - we can just use that instead of pingr::is_online. Thank you for trying out other options!

jeffreyhanson commented 5 years ago

@neriiacopo, could you please try installing the developmental version of wdpar on GitHub (e.g. using the R code devtools::install_github("prioritizr/wdpar")) and try running the example code for wdpa_fetch (see https://prioritizr.github.io/wdpar/reference/wdpa_fetch.html) to see if it works for you?

neriiacopo commented 5 years ago

The examples work smoothly now! Thank you so much!

ankemueller commented 5 years ago

Does also work now for me, thanks a lot!

jeffreyhanson commented 5 years ago

Awesome - glad to hear it's working. I'll submit the new version to CRAN.

ColineBoonman commented 2 years ago

Hi Jeffrey,

I'm still getting the error that I do not have internet connection while running wdpa_fetch(). Following curl::has_internet tells me I am off line, but pingr::is_online() says (correctly) that I am online. It would be great if you could you help me out!!

I have downloaded the package both via github and via R directly, but both versions do not seem to work. I am using a windows machine if that makes a difference.

Thanks in advance for your response :) Coline

jeffreyhanson commented 2 years ago

Hi @ColineBoonman,

Thanks for reaching out! Just to check, could you please try re-installing curl to ensure that you have the latest version of curl installed? If wdpar still fails after that, I can update it so that it will think there is an active internet connection if either pingr or curl indicate an online connection.

ColineBoonman commented 2 years ago

Thanks for your quick response. I have re-installed curl, and it still says I don't have an internet connection > curl::has_internet() [1] FALSE (while pingr gives the opposite response: > pingr::is_online() [1] TRUE).

When I load the wdpar library and run the following line: lie_raw_data <- wdpa_fetch("Liechtenstein", wait = TRUE) I get this Error: Error in wdpa_fetch("Liechtenstein", wait = TRUE) : data not found in download_dir, and no internet connectionto download it.

It would be great if you could include the test of both pingr and curl to check for internet connection!

jeffreyhanson commented 2 years ago

@ColineBoonman, I'm so sorry - I missed the GitHub notification email for your post. I'll work on updating this now and let you know when it's ready.

jeffreyhanson commented 2 years ago

@ColineBoonman, I've just pushed a branch with the new pingr + curl internet checks. Could you please try it out and see if that fixes it for you? You can install it with remotes::install_github("prioritizr/wdpar@int-check").

jeffreyhanson commented 2 years ago

@ColineBoonman, I just wanted wanted to follow up and check if those updates fixed the issue?

ColineBoonman commented 2 years ago

I am sorry for my late response. It works now!! Thank you so much!

jeffreyhanson commented 2 years ago

No worries - thanks for confirming that it works now! I'll merge the fix into the main branch.

jeffreyhanson commented 2 years ago

Fixed by a93a5c40947d582d7ab35ccf29347524193c9d6b