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

Error in data import related to folder path #6

Closed FerreiraPSM closed 5 years ago

FerreiraPSM commented 5 years ago

Congratulations for the initiative. I believe it will be of great help to my thesis I would like to inform you that I am not able to reproduce the example available in the package manual, In the first command line "mlt_raw_pa_data <- wdpa_fetch (" Malta ", wait = TRUE)" the following warning appears:

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

I have already tried inserting the current directory into download_dir in different ways, but without success. I'm also connected to the internet Thank you

jeffreyhanson commented 5 years ago

Thanks! Just to double check, the code in your post has extra spaces around the name Malta, when you tried running the code did it include those spaces? If so, that might be causing the problem, and so you'll need to run it without the spaces. E.g. something like this should work:

mlt_raw_pa_data <- wdpa_fetch ("Malta", wait = TRUE)
jeffreyhanson commented 5 years ago

Also, could you please try running the code below to see if R can successfully detect if you have a working internet connection:

pingr::is_online()
FerreiraPSM commented 5 years ago

I tried again by checking the spaces and had the same problem. The problem really seems to be that my R is not identifying the internet connection because the "pingr :: is_online ()" command returned FALSE Thank you

jeffreyhanson commented 5 years ago

Ah - if there's an issue with pingr then I don't think there's any changes I can make to wdpar that would fix your problem - maybe you could open an issue on the pingr repository? As a work around though, you could download a zip file from protectedplanet.net that contains the WDPA data you want in shapefile format, and read it into R using wdpa_read (https://prioritizr.github.io/wdpar/reference/wdpa_read.html).

For example, something like this might work:

# set file path for data - change this to specify the file path for your data
path <- "C:\\Users\\USERNAME\\Documents\\Downloads\\data.zip"
# load in raw data
raw_data <- wdpa_read(path)
# clean data
cleaned_data <- wdpa_clean(raw_data)
# display cleaned data
print(cleaned_data)
FerreiraPSM commented 5 years ago

This worked perfectly, thanks a lot!

jeffreyhanson commented 5 years ago

No worries - sorry about the issues with pingr - I'll close issue since I don't think anything more I can do.