diff --git a/CITATION.cff b/CITATION.cff index a7788374..6a0f9188 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,5 +1,5 @@ # ----------------------------------------------------------- -# CITATION file created with {cffr} R package, v0.5.0 +# CITATION file created with {cffr} R package, v1.0.0 # See also: https://docs.ropensci.org/cffr/ # ----------------------------------------------------------- @@ -67,11 +67,10 @@ references: url: https://www.R-project.org/ authors: - name: R Core Team - location: - name: Vienna, Austria - year: '2024' institution: name: R Foundation for Statistical Computing + address: Vienna, Austria + year: '2024' version: '>= 3.6.0' - type: software title: countrycode @@ -98,17 +97,6 @@ references: email: dcooley@symbolix.com.au year: '2024' version: '>= 2.0.0' -- type: software - title: httr - abstract: 'httr: Tools for Working with URLs and HTTP' - notes: Imports - url: https://httr.r-lib.org/ - repository: https://CRAN.R-project.org/package=httr - authors: - - family-names: Wickham - given-names: Hadley - email: hadley@posit.co - year: '2024' - type: software title: rappdirs abstract: 'rappdirs: Application Directories: Determine Where to Save Data, Caches, @@ -144,11 +132,10 @@ references: notes: Imports authors: - name: R Core Team - location: - name: Vienna, Austria - year: '2024' institution: name: R Foundation for Statistical Computing + address: Vienna, Austria + year: '2024' - type: software title: eurostat abstract: 'eurostat: Tools for Eurostat Open Data' @@ -201,8 +188,23 @@ references: - family-names: Dunnington given-names: Dewey orcid: https://orcid.org/0000-0002-9415-4582 + - family-names: Brand + given-names: Teun + name-particle: van den + orcid: https://orcid.org/0000-0002-9335-7468 year: '2024' version: '>= 3.0.0' +- type: software + title: httr2 + abstract: 'httr2: Perform HTTP Requests and Process the Responses' + notes: Suggests + url: https://httr2.r-lib.org + repository: https://CRAN.R-project.org/package=httr2 + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@rstudio.com + year: '2024' - type: software title: knitr abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R' @@ -219,7 +221,7 @@ references: title: lwgeom abstract: 'lwgeom: Bindings to Selected ''liblwgeom'' Functions for Simple Features' notes: Suggests - url: https://github.com/r-spatial/lwgeom/ + url: https://r-spatial.github.io/lwgeom/ repository: https://CRAN.R-project.org/package=lwgeom authors: - family-names: Pebesma diff --git a/DESCRIPTION b/DESCRIPTION index 439d1932..2e608cfd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,13 +24,13 @@ Depends: Imports: countrycode (>= 1.2.0), geojsonsf (>= 2.0.0), - httr, rappdirs (>= 0.3.0), sf (>= 0.9.0), utils Suggests: eurostat, ggplot2 (>= 3.0.0), + httr2, knitr, lwgeom (>= 0.2-2), rmarkdown, @@ -38,9 +38,9 @@ Suggests: VignetteBuilder: knitr Config/Needs/website: ropengov/rogtemplate, ragg, reactable, styler, - devtools + devtools, remotes Config/testthat/edition: 3 -Config/testthat/parallel: false +Config/testthat/parallel: true Copyright: General Copyright © European Union, 1995 - today. See file COPYRIGHTS for specific provisions. Encoding: UTF-8 diff --git a/NEWS.md b/NEWS.md index 8e8da42f..9ae1ceef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,8 @@ # giscoR (development version) - Improve documentation, stating where the parameters `country` and `region` - applies (#50, #75) + applies (#50, #75). +- Migrate to **httr2** instead of **httr**. # giscoR 0.4.0 diff --git a/R/gisco_get_healthcare.R b/R/gisco_get_healthcare.R index 92753ee6..a581d186 100644 --- a/R/gisco_get_healthcare.R +++ b/R/gisco_get_healthcare.R @@ -1,4 +1,4 @@ -#' Get locations of healthcare services in Europe. +#' Get locations of healthcare services in Europe #' #' @concept infrastructure #' @family infrastructure diff --git a/R/utils_downloads.R b/R/utils_downloads.R index 467ea356..16451b2f 100644 --- a/R/utils_downloads.R +++ b/R/utils_downloads.R @@ -301,21 +301,21 @@ gsc_api_cache <- )) } - # Last try with httr (#69) + # Last try with httr2 (#69) if (inherits(err_dwnload, "try-error")) { - ops <- options() - options(timeout = 1000) - req <- try(httr::GET(url, httr::write_disk(file_local, overwrite = TRUE)), - silent = TRUE - ) - options(ops) + req <- httr2::request(url) + req <- httr2::req_error(req, is_error = function(x) { + FALSE + }) + req <- httr2::req_timeout(req, 100000) + resp <- httr2::req_perform(req, file_local) # Mock err download - if (inherits(req, "try-error")) { + if (httr2::resp_is_error(resp)) { mock_er <- "aaaa" unlink(file_local) - } else if (httr::status_code(req) == 200) { + } else if (httr2::resp_status(resp) == 200) { mock_er <- 200 } else { mock_er <- "aaaa" @@ -326,6 +326,10 @@ gsc_api_cache <- } # If not then stop if (inherits(err_dwnload, "try-error")) { + gsc_message( + TRUE, "HTTP Status Code:", httr2::resp_status(resp), + "-", httr2::resp_status_desc(resp) + ) gsc_message( TRUE, "\nurl \n ", diff --git a/README.Rmd b/README.Rmd index a88b0fbf..5ea48896 100644 --- a/README.Rmd +++ b/README.Rmd @@ -49,9 +49,9 @@ Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repost -[giscoR](https://ropengov.github.io/giscoR//) is an API package that helps to -retrieve data from [Eurostat - GISCO (the Geographic Information System of the -COmmission)](https://ec.europa.eu/eurostat/web/gisco). It also provides some +[**giscoR**](https://ropengov.github.io/giscoR//) is an API package that helps +to retrieve data from [Eurostat - GISCO (the Geographic Information System of +the COmmission)](https://ec.europa.eu/eurostat/web/gisco). It also provides some lightweight data sets ready to use without downloading. [GISCO](https://ec.europa.eu/eurostat/web/gisco) is a geospatial open data @@ -68,20 +68,20 @@ Full site with examples and vignettes on ## Installation -Install `giscoR` from [**CRAN**](https://CRAN.R-project.org/package=giscoR): +Install **giscoR** from [**CRAN**](https://CRAN.R-project.org/package=giscoR): ```{r, eval=FALSE} install.packages("giscoR") ``` -You can install the developing version of `giscoR` with: +You can install the developing version of **giscoR** with: ```{r, eval=FALSE} library(remotes) install_github("rOpenGov/giscoR") ``` -Alternatively, you can install `giscoR` using the +Alternatively, you can install **giscoR** using the [r-universe](https://ropengov.r-universe.dev/giscoR): ```{r, eval=FALSE} @@ -105,7 +105,7 @@ if (length(l) == 4) { } ``` -This script highlights some features of `giscoR`: +This script highlights some features of **giscoR** : ```{r example} library(giscoR) @@ -165,7 +165,7 @@ ggplot(coast) + ### Labels -An example of a labeled map using `ggplot2`: +An example of a labeled map using **ggplot2**: ```{r labels, fig.height=7, fig.width=6} ITA <- gisco_get_nuts(country = "Italy", nuts_level = 1) @@ -178,10 +178,10 @@ ggplot(ITA) + ### Thematic maps -An example of a thematic map plotted with the `ggplot2` package. The information -is extracted via the `eurostat` package. We would follow the fantastic approach -presented by [Milos Popovic](https://milospopovic.net/) on [this -post](https://milospopovic.net/how-to-make-choropleth-map-in-r/): +An example of a thematic map plotted with the **ggplot2** package. The +information is extracted via the **eurostat** package. We would follow the +fantastic approach presented by [Milos Popovic](https://milospopovic.net/) on +[this post](https://milospopovic.net/how-to-make-choropleth-map-in-r/): ```{r eurostat_install, include = FALSE} if (isFALSE(requireNamespace("eurostat", quietly = TRUE))) { @@ -322,8 +322,8 @@ ggplot(nuts3.sf) + ## A note on caching Some data sets (as Local Administrative Units - LAU, or high-resolution files) -may have a size larger than 50MB. You can use `giscoR` to create your own local -repository at a given local directory passing the following function: +may have a size larger than 50MB. You can use **giscoR** to create your own +local repository at a given local directory passing the following function: ```{r, eval=FALSE} gisco_set_cache_dir("./path/to/location") @@ -336,18 +336,19 @@ your local directory. ### API data packages -- `eurostat` package (). This is an API - package that provides access to open data from Eurostat. +- **eurostat** package (). This is an + API package that provides access to open data from Eurostat. -### Plotting `sf` objects +### Plotting **sf** objects Some packages recommended for visualization are: -- [`tmap`](https://r-tmap.github.io/tmap/) -- [`ggplot2`](https://github.com/tidyverse/ggplot2) + - [`ggspatial`](https://github.com/paleolimbot/ggspatial) -- [`mapsf`](https://riatelab.github.io/mapsf/) -- [`leaflet`](https://rstudio.github.io/leaflet/) +- [**tmap**](https://r-tmap.github.io/tmap/) +- [**ggplot2**](https://github.com/tidyverse/ggplot2) + + [**ggspatial**](https://github.com/paleolimbot/ggspatial) + + [**tidyterra**](https://dieghernan.github.io/tidyterra/) +- [**mapsf**](https://riatelab.github.io/mapsf/) +- [**leaflet**](https://rstudio.github.io/leaflet/) ## Contribute diff --git a/README.md b/README.md index 72d4d114..9c05560a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repost -[giscoR](https://ropengov.github.io/giscoR//) is an API package that +[**giscoR**](https://ropengov.github.io/giscoR//) is an API package that helps to retrieve data from [Eurostat - GISCO (the Geographic Information System of the COmmission)](https://ec.europa.eu/eurostat/web/gisco). It also provides @@ -44,21 +44,21 @@ Full site with examples and vignettes on ## Installation -Install `giscoR` from +Install **giscoR** from [**CRAN**](https://CRAN.R-project.org/package=giscoR): ``` r install.packages("giscoR") ``` -You can install the developing version of `giscoR` with: +You can install the developing version of **giscoR** with: ``` r library(remotes) install_github("rOpenGov/giscoR") ``` -Alternatively, you can install `giscoR` using the +Alternatively, you can install **giscoR** using the [r-universe](https://ropengov.r-universe.dev/giscoR): ``` r @@ -72,7 +72,7 @@ install.packages("giscoR", You can have a look to the documentation of the dev version in -This script highlights some features of `giscoR`: +This script highlights some features of **giscoR** : ``` r library(giscoR) @@ -139,7 +139,7 @@ ggplot(coast) + ### Labels -An example of a labeled map using `ggplot2`: +An example of a labeled map using **ggplot2**: ``` r ITA <- gisco_get_nuts(country = "Italy", nuts_level = 1) @@ -154,9 +154,9 @@ ggplot(ITA) + ### Thematic maps -An example of a thematic map plotted with the `ggplot2` package. The -information is extracted via the `eurostat` package. We would follow the -fantastic approach presented by [Milos +An example of a thematic map plotted with the **ggplot2** package. The +information is extracted via the **eurostat** package. We would follow +the fantastic approach presented by [Milos Popovic](https://milospopovic.net/) on [this post](https://milospopovic.net/how-to-make-choropleth-map-in-r/): @@ -281,8 +281,8 @@ ggplot(nuts3.sf) + ## A note on caching Some data sets (as Local Administrative Units - LAU, or high-resolution -files) may have a size larger than 50MB. You can use `giscoR` to create -your own local repository at a given local directory passing the +files) may have a size larger than 50MB. You can use **giscoR** to +create your own local repository at a given local directory passing the following function: ``` r @@ -296,18 +296,19 @@ them on your local directory. ### API data packages -- `eurostat` package (). This is +- **eurostat** package (). This is an API package that provides access to open data from Eurostat. -### Plotting `sf` objects +### Plotting **sf** objects Some packages recommended for visualization are: -- [`tmap`](https://r-tmap.github.io/tmap/) -- [`ggplot2`](https://github.com/tidyverse/ggplot2) + - [`ggspatial`](https://github.com/paleolimbot/ggspatial) -- [`mapsf`](https://riatelab.github.io/mapsf/) -- [`leaflet`](https://rstudio.github.io/leaflet/) +- [**tmap**](https://r-tmap.github.io/tmap/) +- [**ggplot2**](https://github.com/tidyverse/ggplot2) + + [**ggspatial**](https://github.com/paleolimbot/ggspatial) + + [**tidyterra**](https://dieghernan.github.io/tidyterra/) +- [**mapsf**](https://riatelab.github.io/mapsf/) +- [**leaflet**](https://rstudio.github.io/leaflet/) ## Contribute diff --git a/codemeta.json b/codemeta.json index c58350d7..61441410 100644 --- a/codemeta.json +++ b/codemeta.json @@ -14,7 +14,7 @@ "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", + "runtimePlatform": "R version 4.3.3 (2024-02-29 ucrt)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -84,6 +84,18 @@ }, "sameAs": "https://CRAN.R-project.org/package=ggplot2" }, + { + "@type": "SoftwareApplication", + "identifier": "httr2", + "name": "httr2", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=httr2" + }, { "@type": "SoftwareApplication", "identifier": "knitr", @@ -169,18 +181,6 @@ "sameAs": "https://CRAN.R-project.org/package=geojsonsf" }, "4": { - "@type": "SoftwareApplication", - "identifier": "httr", - "name": "httr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=httr" - }, - "5": { "@type": "SoftwareApplication", "identifier": "rappdirs", "name": "rappdirs", @@ -193,7 +193,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=rappdirs" }, - "6": { + "5": { "@type": "SoftwareApplication", "identifier": "sf", "name": "sf", @@ -206,7 +206,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=sf" }, - "7": { + "6": { "@type": "SoftwareApplication", "identifier": "utils", "name": "utils" @@ -216,7 +216,7 @@ "applicationCategory": "cartography", "isPartOf": "http://ropengov.org/", "keywords": ["ropengov", "r", "spatial", "api-wrapper", "rstats", "r-package", "eurostat", "gisco", "thematic-maps", "eurostat-data", "cran", "ggplot2", "gis"], - "fileSize": "1117.242KB", + "fileSize": "1116.79KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/data/gisco_coastallines.rda b/data/gisco_coastallines.rda index deabc605..f8840b97 100644 Binary files a/data/gisco_coastallines.rda and b/data/gisco_coastallines.rda differ diff --git a/data/gisco_countries.rda b/data/gisco_countries.rda index 97a914f0..2a89a60a 100644 Binary files a/data/gisco_countries.rda and b/data/gisco_countries.rda differ diff --git a/data/gisco_countrycode.rda b/data/gisco_countrycode.rda index 28b39a56..990ba5e9 100644 Binary files a/data/gisco_countrycode.rda and b/data/gisco_countrycode.rda differ diff --git a/data/gisco_db.rda b/data/gisco_db.rda index 37d95148..6fcb9cf0 100644 Binary files a/data/gisco_db.rda and b/data/gisco_db.rda differ diff --git a/data/gisco_nuts.rda b/data/gisco_nuts.rda index a382f7d1..19f8dc69 100644 Binary files a/data/gisco_nuts.rda and b/data/gisco_nuts.rda differ diff --git a/data/tgs00026.rda b/data/tgs00026.rda index 1d559b89..b03546f3 100644 Binary files a/data/tgs00026.rda and b/data/tgs00026.rda differ diff --git a/img/README-example-1.png b/img/README-example-1.png index 9dac181f..97f84e4e 100644 Binary files a/img/README-example-1.png and b/img/README-example-1.png differ diff --git a/img/README-example-2.png b/img/README-example-2.png index 94e98c63..b2001353 100644 Binary files a/img/README-example-2.png and b/img/README-example-2.png differ diff --git a/img/README-labels-1.png b/img/README-labels-1.png index cc2855c3..865765bc 100644 Binary files a/img/README-labels-1.png and b/img/README-labels-1.png differ diff --git a/img/README-thematic-1.png b/img/README-thematic-1.png index 21bba86b..3435967e 100644 Binary files a/img/README-thematic-1.png and b/img/README-thematic-1.png differ diff --git a/inst/WORDLIST b/inst/WORDLIST index b6f72de0..35838473 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,5 +1,4 @@ Arel -BN Bundock CMD CNTR @@ -12,7 +11,6 @@ EPSG ETRS Eurostat FID -FUA GISCO Gb Geodata @@ -39,7 +37,7 @@ codelist config countrycode der -df +dev dieghernan dir eurostat diff --git a/inst/schemaorg.json b/inst/schemaorg.json index 4297ed6c..285ab2cf 100644 --- a/inst/schemaorg.json +++ b/inst/schemaorg.json @@ -40,7 +40,7 @@ "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", + "runtimePlatform": "R version 4.3.3 (2024-02-29 ucrt)", "version": "0.4.0.9000" }, { diff --git a/man/gisco_get_healthcare.Rd b/man/gisco_get_healthcare.Rd index dc3d7774..41540607 100644 --- a/man/gisco_get_healthcare.Rd +++ b/man/gisco_get_healthcare.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gisco_get_healthcare.R \name{gisco_get_healthcare} \alias{gisco_get_healthcare} -\title{Get locations of healthcare services in Europe.} +\title{Get locations of healthcare services in Europe} \source{ \url{https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/healthcare-services} } diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index a88127dc..4802f8d3 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -1,24 +1,37 @@ url: https://ropengov.github.io/giscoR/ + reference: - title: Political - desc: These functions return `sf` objects with political boundaries + desc: > + These functions return sf objects with political + boundaries. contents: has_concept("political") - title: Infrastructures - desc: These functions return `sf` objects with man-made features + desc: > + These functions return sf objects with man-made + features contents: has_concept("infrastructure") - title: Misc - desc: Thse functions return other `sf` objects + desc: > + These functions return other sf objects contents: has_concept("misc") -- title: Cache management +- title: > + Cache management contents: has_concept("cache utilities") - title: Helpers - desc: A collection of helper functions + desc: > + A collection of helper functions contents: has_concept("helper") - title: Datasets - desc: These objects are datasets already included in the package. + desc: > + These objects are datasets already included in the package. contents: has_concept("dataset") - title: About the package contents: giscoR-package + template: package: rogtemplate params: @@ -29,10 +42,10 @@ template: card: summary_large_image home: title: giscoR | R package for download geodata from GISCO - Eurostat - description: giscoR is a R API package that helps to retrieve data from Eurostat - - GISCO (the Geographic Information System of the COmmission). It also provides - some lightweight data sets ready to use without downloading. Currently only the - Administrative Units / Statistical Units data sets are supported + description: > + giscoR is a R API package that helps to retrieve data from Eurostat - + GISCO (the Geographic Information System of the COmmission). It also + provides some lightweight data sets ready to use without downloading. authors: Diego Hernangómez: href: https://dieghernan.github.io/ @@ -42,6 +55,4 @@ authors: href: https://vincentarelbundock.github.io/countrycode/ repo: branch: main -development: - mode: auto diff --git a/pkgdown/favicon/apple-touch-icon-120x120.png b/pkgdown/favicon/apple-touch-icon-120x120.png index 1a06972d..460229cc 100644 Binary files a/pkgdown/favicon/apple-touch-icon-120x120.png and b/pkgdown/favicon/apple-touch-icon-120x120.png differ diff --git a/pkgdown/favicon/apple-touch-icon-152x152.png b/pkgdown/favicon/apple-touch-icon-152x152.png index b3ee98de..8e7e75ba 100644 Binary files a/pkgdown/favicon/apple-touch-icon-152x152.png and b/pkgdown/favicon/apple-touch-icon-152x152.png differ diff --git a/pkgdown/favicon/apple-touch-icon-180x180.png b/pkgdown/favicon/apple-touch-icon-180x180.png index b53eccaf..4564b82d 100644 Binary files a/pkgdown/favicon/apple-touch-icon-180x180.png and b/pkgdown/favicon/apple-touch-icon-180x180.png differ diff --git a/pkgdown/favicon/apple-touch-icon-60x60.png b/pkgdown/favicon/apple-touch-icon-60x60.png index 1fc0ce2b..3b1bedd7 100644 Binary files a/pkgdown/favicon/apple-touch-icon-60x60.png and b/pkgdown/favicon/apple-touch-icon-60x60.png differ diff --git a/pkgdown/favicon/apple-touch-icon-76x76.png b/pkgdown/favicon/apple-touch-icon-76x76.png index a677e824..c1cb8c72 100644 Binary files a/pkgdown/favicon/apple-touch-icon-76x76.png and b/pkgdown/favicon/apple-touch-icon-76x76.png differ diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png index b53eccaf..4564b82d 100644 Binary files a/pkgdown/favicon/apple-touch-icon.png and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-16x16.png b/pkgdown/favicon/favicon-16x16.png index a02df1d4..47f99c8f 100644 Binary files a/pkgdown/favicon/favicon-16x16.png and b/pkgdown/favicon/favicon-16x16.png differ diff --git a/pkgdown/favicon/favicon-32x32.png b/pkgdown/favicon/favicon-32x32.png index 6879a585..e27b0a18 100644 Binary files a/pkgdown/favicon/favicon-32x32.png and b/pkgdown/favicon/favicon-32x32.png differ diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 78df48e9..d5a7d0c8 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -44,10 +44,10 @@ test_that("Errors on database", { expect_message( - n <- gsc_api_cache("https://www.dhh.this.is.fake/", + n <- gsc_api_cache("https://github.com/dieghernan/a_fake_thing_here", verbose = FALSE ), - "https://www.dhh.this.is.fake/ not reachable." + "404" ) expect_null(n) diff --git a/vignettes/giscoR-1.png b/vignettes/giscoR-1.png index b132c3a1..58a4c894 100644 Binary files a/vignettes/giscoR-1.png and b/vignettes/giscoR-1.png differ