-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a34ae3
commit 19184a3
Showing
19 changed files
with
590 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(get_dep_sf) | ||
export(get_prov_sf) | ||
export(get_geo_peru) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#' Download spatial data of Peru | ||
#' | ||
#' Downloads spatial data of Peru using Geodetic reference system "WGRS84" and CRS(4326). | ||
#' | ||
#' @param geography A character or a vector with the name of geographical region. | ||
#' An exception is "all" to request all Peru data. | ||
#' @param level A character: "all" for national level data, "dep" for department | ||
#' level data, and "prov" for provincial level data. | ||
#' @param simplified A logical TRUE or FALSE, to select data with all districts or | ||
#' a polygon simplified to a higher level. | ||
#' @param showProgress Logical TRUE or FALSE to display a progress bar during download. | ||
#' | ||
#' @return An `"sf" "data.frame"` object containing the spatial data of Peru. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' | ||
#' # Read specific province | ||
#' anta <- get_geo_peru(geography = "ANTA", | ||
#' level = "prov", | ||
#' simplified = TRUE) | ||
#' | ||
#' # Read more than one province | ||
#' df <- get_geo_peru(geography = c("ANTA", "URUBAMBA", "la convencion"), | ||
#' level = "prov", | ||
#' simplified = TRUE) | ||
#' | ||
#' # Read department level data | ||
#' cusco <- get_geo_peru(geography = "cusco", | ||
#' level = "dep", | ||
#' simplified = FALSE) | ||
#' | ||
get_geo_peru<- function(geography = "all", | ||
level = "all", | ||
simplified = TRUE, | ||
showProgress = TRUE) { | ||
|
||
# Get metadata with data url addresses | ||
temp_meta <- select_metadata(geography = geography, | ||
level = level, | ||
simplified = simplified) | ||
# check if download failed | ||
if (is.null(temp_meta)) { return(invisible(NULL)) } | ||
|
||
# list paths of files to download | ||
file_url <- as.character(temp_meta$download_path) | ||
# download gpkg | ||
temp_sf <- download_gpkg(file_url, progress_bar = FALSE) | ||
# check if download failed | ||
if (is.null(temp_sf)) { | ||
return(invisible(NULL)) | ||
} | ||
else{ | ||
return(temp_sf) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.