-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leverage on giscoR #264
Leverage on giscoR #264
Changes from 1 commit
51624ad
20b0c32
55134fe
3d98b72
ad7c8c9
756cf9f
3a6e48f
37fce83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,22 +207,33 @@ get_eurostat_geospatial <- function(output_class = "sf", | |
# Check if package "giscoR" is installed | ||
# nocov start | ||
if (!requireNamespace("giscoR")) { | ||
message("'giscoR' package is required for geospatial functionalities") | ||
return(invisible()) | ||
} | ||
|
||
if (!requireNamespace("sf")) { | ||
message("'sf' package is required for geospatial functionalities") | ||
return(invisible()) | ||
} | ||
# nocov end | ||
|
||
message("Extracting data using giscoR package") | ||
message(paste0( | ||
"Extracting data using giscoR package, please report issues", | ||
" on https://github.com/rOpenGov/giscoR/issues" | ||
)) | ||
|
||
# Manage cache: Priority is eurostat cache (if set) | ||
# If not make use of giscoR default options | ||
detect_eurostat_cache <- eur_helper_detect_cache_dir() | ||
if (!is.null(cache_dir)) { | ||
# Already set by the user, no need message | ||
cache_dir <- eur_helper_cachedir(cache_dir) | ||
} else if (identical(detect_eurostat_cache, file.path(tempdir(), "eurostat"))) { | ||
} else if (identical( | ||
detect_eurostat_cache, | ||
file.path(tempdir(), "eurostat") | ||
)) { | ||
# eurostat not set, using default giscoR cache management | ||
message("Cache management as per giscoR. see 'giscoR::gisco_get_nuts()") | ||
message("Cache management as per giscoR. see 'giscoR::gisco_get_nuts()'") | ||
} else { | ||
cache_dir <- eur_helper_cachedir(cache_dir) | ||
} | ||
|
@@ -241,20 +252,17 @@ get_eurostat_geospatial <- function(output_class = "sf", | |
|
||
# Just to capture potential NULL outputs from giscoR - this happen | ||
# on some errors | ||
# nocov start | ||
if (is.null(shp)) { | ||
return(NULL) | ||
} | ||
# nocov end | ||
|
||
# Post-data treatments | ||
|
||
# Adding a `geo` column for easier joins with dplyr | ||
shp$geo <- shp$NUTS_ID | ||
# to df | ||
if (output_class == "df") { | ||
# Convert yl df | ||
sf_col <- attr(shp, "sf_column") | ||
# Remove geometry | ||
shp <- sf::st_drop_geometry(shp) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though this PR was already merged I noticed a logical problem that originated here:
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this PR was already merged I noticed a logical problem that originated here:
!requireNamespace("sf")
check is not run ifuse_local == TRUE
This causes problems later on in rows 265:267 (see another comment)