Skip to content

Commit

Permalink
new funtions
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulESantos committed Mar 18, 2024
1 parent 9a34ae3 commit 19184a3
Show file tree
Hide file tree
Showing 19 changed files with 590 additions and 275 deletions.
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: geoperu
Title: Descarga de Conjuntos de Datos Espaciales Oficiales de Perú
Version: 1.0.0
Title: Download Official Spatial Datasets of Peru
Version: 0.0.0.1
Authors@R:
person("Paul E.", "Santos Andrade",
email = "paulefrens@gmail.com",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6635-0375"))
Description: Proporciona acceso conveniente a los conjuntos de datos espaciales oficiales de Perú como objetos 'sf' en R. Este paquete incluye una amplia gama de datos geoespaciales que cubren varios aspectos de la geografía peruana, como divisiones administrativas, cobertura terrestre, elevación, hidrografía y más. Todos los conjuntos de datos están armonizados en términos de atributos, proyección y topología, asegurando consistencia y facilidad de uso para el análisis y visualización espacial.
Description: Provides convenient access to the official spatial datasets of Peru as 'sf' objects in R. This package includes a wide range of geospatial data covering various aspects of Peruvian geography, such as administrative divisions, land cover, elevation, hydrography, and more. All datasets are harmonized in terms of attributes, projection, and topology, ensuring consistency and ease of use for spatial analysis and visualization.
License: MIT + file LICENSE
Suggests:
testthat (>= 3.0.0)
Expand All @@ -21,6 +21,8 @@ LazyDataCompression: xz
LazyData: true
URL: https://github.com/PaulESantos/geoperu, https://paulesantos.github.io/geoperu/
Imports:
dplyr,
curl,
data.table,
httr,
methods,
sf
3 changes: 1 addition & 2 deletions NAMESPACE
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)
43 changes: 0 additions & 43 deletions R/get_dep.R

This file was deleted.

58 changes: 58 additions & 0 deletions R/get_geo_peru.R
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)
}

}
41 changes: 0 additions & 41 deletions R/get_prov.R

This file was deleted.

4 changes: 3 additions & 1 deletion R/global.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
utils::globalVariables(c( ".data", "provincia", "departamento"
utils::globalVariables(c( ".data", "provincia", "departamento",
"dep_name", "prov_name", "file_url", "file_url2",
"showProgress", "tail"
))


Expand Down
68 changes: 0 additions & 68 deletions R/internal.R

This file was deleted.

Loading

0 comments on commit 19184a3

Please sign in to comment.