According to https://info.figshare.com/ :
Figshare’s industry leading repository infrastructure offers a single solution for storing and sharing data, papers, theses, media and much more
We are going to download the data from Ferrer-Paris (2018 ) directly from the figshare downloader link using functions from package jsonlite in R.
Local folder
First we will create a local folder to keep the data handy for analysis and then we will download the necessary data from different cloud storage services and repositories.
here:: i_am ("data-preparation/download-osf.qmd" )
here() starts at /Users/z3529065/proyectos/Forests-Americas/RLE-example-dry-forest-guajira
target_dir <- "downloaded-data"
if (! file.exists (here:: here (target_dir)))
dir.create (here:: here (target_dir))
Download from figshare
First we load the jsonlite library:
We use the function read_json to parse the request for the article ID:
article_id <- '7488872'
response <- read_json (sprintf ("https://api.figshare.com/v2/articles/%s" , article_id))
The url we need is somewhere in the response:
List of 48
$ files :List of 1
$ authors :List of 1
$ custom_fields : list()
$ figshare_url : chr "https://figshare.com/articles/dataset/IUCN_Red_List_of_Ecosystem_assessment_results_for_IVC_Forest_Macrogroups_"| __truncated__
$ download_disabled : logi FALSE
$ description : chr "Tables summarizing the results of the IUCN Red List of Ecosystems assessment of 136 tropical and temperate (exc"| __truncated__
$ funding : chr "Gordon and Betty Moore Foundation, Grant/Award Number: 3123"
$ funding_list :List of 2
$ version : int 1
$ status : chr "public"
$ size : int 83334
$ created_date : chr "2018-12-20T02:26:27Z"
$ modified_date : chr "2023-05-31T17:01:55Z"
$ is_public : logi TRUE
$ is_confidential : logi FALSE
$ is_metadata_record : logi FALSE
$ confidential_reason: chr "Publication scheduled for 2019-01-15"
$ metadata_reason : chr ""
$ license :List of 3
$ tags :List of 9
$ categories :List of 1
$ references :List of 1
$ has_linked_file : logi FALSE
$ citation : chr "Ferrer-Paris, José R. (2018). IUCN Red List of Ecosystem assessment results for IVC Forest Macrogroups in the A"| __truncated__
$ related_materials :List of 1
$ is_embargoed : logi FALSE
$ embargo_date : chr "2019-01-15"
$ embargo_type : NULL
$ embargo_title : chr ""
$ embargo_reason : chr "Publication scheduled for 2019-01-15"
$ embargo_options : list()
$ id : int 7488872
$ title : chr "IUCN Red List of Ecosystem assessment results for IVC Forest Macrogroups in the Americas region"
$ doi : chr "10.6084/m9.figshare.7488872.v1"
$ handle : chr ""
$ url : chr "https://api.figshare.com/v2/articles/7488872"
$ published_date : chr "2018-12-20T02:26:27Z"
$ thumb : chr ""
$ defined_type : int 3
$ defined_type_name : chr "dataset"
$ group_id : NULL
$ url_private_api : chr "https://api.figshare.com/v2/account/articles/7488872"
$ url_public_api : chr "https://api.figshare.com/v2/articles/7488872"
$ url_private_html : chr "https://figshare.com/account/articles/7488872"
$ url_public_html : chr "https://figshare.com/articles/dataset/IUCN_Red_List_of_Ecosystem_assessment_results_for_IVC_Forest_Macrogroups_"| __truncated__
$ timeline :List of 2
$ resource_title : NULL
$ resource_doi : NULL
str (response$ files[[1 ]],1 )
List of 8
$ id : int 13874333
$ name : chr "20181123_MacrogroupsCountry.rda"
$ size : int 83334
$ is_link_only: logi FALSE
$ download_url: chr "https://ndownloader.figshare.com/files/13874333"
$ supplied_md5: chr "4f6a59c01dfdab2541493ccfb28b9feb"
$ computed_md5: chr "4f6a59c01dfdab2541493ccfb28b9feb"
$ mimetype : chr "application/gzip"
This is the info that we need:
url_source <- response$ files[[1 ]]$ download_url
dst_name <- response$ files[[1 ]]$ name
We use download.file to download from the source url to the destination path:
dst_path <- here:: here (target_dir, dst_name)
if (! file.exists (dst_path))
download.file (url_source, dst_path)
We can test the download with:
[1] "Macrogroups.Global" "Macrogroups.Country"
[3] "SpatialCriteria.Global" "SpatialCriteria.Country"
[5] "FunctionalCriteria.Global" "FunctionalCriteria.Country"
The R objects with a .Global suffix have the information for the global (i.e. ontinental) assessments, and the ones with .Country suffix have the information for the assessments within country boundaries.
Ferrer-Paris, José Rafael. 2018.
“IUCN Red List of Ecosystem assessment results for IVC Forest Macrogroups in the Americas region .” figshare.
https://doi.org/10.6084/m9.figshare.7488872.v1 .