Skip to content

Commit

Permalink
Examples and fix based in httr
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Oct 24, 2023
1 parent 5a238fd commit 7f1d223
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ references:
email: [email protected]
year: '2023'
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: [email protected]
year: '2023'
- type: software
title: rappdirs
abstract: 'rappdirs: Application Directories: Determine Where to Save Data, Caches,
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Depends:
Imports:
countrycode (>= 1.2.0),
geojsonsf (>= 2.0.0),
httr,
rappdirs (>= 0.3.0),
sf (>= 0.9.0),
utils
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

- `gisco_get_nuts()`: Add an additional `geo` column (identical to `NUTS_ID`)
for enhanced compatibility with **eurostat** package (#62).
- Adjust examples for **CRAN**.
- Add dependency **httr**.

# giscoR 0.3.5

- Review examples to avoid CRAN errors and notes.

- New helper function: `gisco_detect_cache_dir()`.

- Now the functions fail gracefully with an informative message, instead of an
error, and return `NULL`.

Expand Down
2 changes: 1 addition & 1 deletion R/gisco_get_airports.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#' ##############################
#'
#' ports <- gisco_get_ports()
#' coast <- gisco_get_coastallines(year = 2013)
#' coast <- giscoR::gisco_coastallines
#'
#' # To Equal Earth projection :)
#'
Expand Down
17 changes: 17 additions & 0 deletions R/utils_downloads.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,23 @@ gsc_api_cache <-
))
}

# Last try with httr (#69)

if (inherits(err_dwnload, "try-error")) {
ops <- options()
options(timeout = 1000)
req <- httr::GET(url, httr::write_disk(file_local, overwrite = TRUE))
options(ops)

# Mock err download
if (httr::status_code(req) == 200) {
mock_er <- 200
} else {
mock_er <- "aaaa"
}

err_dwnload <- try(mock_er / 2, silent = TRUE)
}
# If not then stop
if (inherits(err_dwnload, "try-error")) {
gsc_message(
Expand Down
8 changes: 4 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ 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 repository including several data sets as countries, coastal lines, labels
or [NUTS levels](https://ec.europa.eu/eurostat/web/regions-and-cities/overview).
[GISCO](https://ec.europa.eu/eurostat/web/gisco) is a geospatial open data
repository including several data sets as countries, coastal lines, labels or
[NUTS levels](https://ec.europa.eu/eurostat/web/regions-and-cities/overview).
The data sets are usually provided at several resolution levels
(60M/20M/10M/03M/01M) and in 3 different projections (4326/3035/3857).

Expand Down Expand Up @@ -223,7 +223,7 @@ for (i in 1:5) {
if (inherits(popdens, "data.frame")) break
}
popdens <- popdens %>% filter(time == "2018-01-01")
popdens <- popdens %>% filter(TIME_PERIOD == "2018-01-01")
```

``` r
Expand Down
18 changes: 15 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@
"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",
Expand All @@ -181,7 +193,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=rappdirs"
},
"5": {
"6": {
"@type": "SoftwareApplication",
"identifier": "sf",
"name": "sf",
Expand All @@ -194,7 +206,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=sf"
},
"6": {
"7": {
"@type": "SoftwareApplication",
"identifier": "utils",
"name": "utils"
Expand All @@ -204,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": "1421.165KB",
"fileSize": "1421.519KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
2 changes: 1 addition & 1 deletion man/gisco_get_airports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f1d223

Please sign in to comment.