Title: Download Spatial Datasets of Peru
Version: 0.0.0.2
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 (Source: INEI https://ide.inei.gob.pe/), protected natural areas (Source: GEO ANP - SERNANP https://geo.sernanp.gob.pe/visorsernanp/). 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)
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.1
BugReports: https://github.com/PaulESantos/geoperu/issues
Depends: R (≥ 3.6.0)
LazyDataCompression: xz
LazyData: true
URL: https://github.com/PaulESantos/geoperu, https://paulesantos.github.io/geoperu/
Imports: curl, data.table, httr, methods, sf
NeedsCompilation: no
Packaged: 2024-04-01 02:43:09 UTC; paule
Author: Paul E. Santos Andrade ORCID iD [aut, cre]
Maintainer: Paul E. Santos Andrade <paulefrens@gmail.com>
Repository: CRAN
Date/Publication: 2024-04-01 08:10:02 UTC

Check internet connection with GitHub repository

Description

Checks if there is an internet connection with GitHub to download data.

Usage

check_connection(
  url = paste0("https://raw.githubusercontent.com/PaulESantos/",
    "perugeopkg/master/metadata_peru_gpkg.csv"),
  silent = FALSE
)

Arguments

url

A string with the url address of an perugpkg dataset

silent

Logical. Throw a message when silent is FALSE (default)

Value

Logical. TRUE if url is working, FALSE if not.


Check internet connection with GitHub repository

Description

Checks if there is an internet connection with GitHub to download data.

Usage

check_connection_anp(
  url = paste0("https://raw.githubusercontent.com/", "PaulESantos/perugeopkg/master/",
    "metadata_anp.csv"),
  silent = FALSE
)

Arguments

url

A string with the url address of an perugpkg dataset

silent

Logical. Throw a message when silent is FALSE (default)

Value

Logical. TRUE if url is working, FALSE if not.


Download geopackage to tempdir

Description

Download geopackage to tempdir

Usage

download_gpkg(file_url, progress_bar = showProgress)

Arguments

file_url

A string with the file_url address of a geobr dataset

progress_bar

Logical. Defaults to (TRUE) display progress bar


Download geopackage to tempdir

Description

Download geopackage to tempdir

Usage

download_gpkg_anp(file_url, progress_bar = showProgress)

Arguments

file_url

A string with the file_url address of a geobr dataset

progress_bar

Logical. Defaults to (TRUE) display progress bar


Support function to download metadata internally used

Description

Support function to download metadata internally used

Usage

download_metadata()

Support function to download metadata internally used for anp data

Description

Support function to download metadata internally used for anp data

Usage

download_metadata_anp()

Download Spatial Data of Protected Natural Areas (ANP) in Peru

Description

Downloads spatial data of protected natural areas in Peru declared by SERNAP (National Service of Natural Protected Areas). Data were obtained from GEO ANP as the official source. The data are in the "WGRS84" reference system and CRS(4326).

Usage

get_anp_peru(anp = NULL, showProgress = TRUE)

Arguments

anp

A character or a vector with the name(s) of the protected natural areas in Peru.

showProgress

Logical TRUE or FALSE to display a progress bar during download.

Value

An ⁠"sf" "data.frame"⁠ object containing the spatial data of Peru's protected natural areas.

Examples


# Read specific ANP
manu <- get_anp_peru(anp = "Manu")

pampa_galeras <- get_anp_peru(anp = "Pampa Galeras")

# Read more than one ANP
anps <- get_anp_peru(anp = c("Manu", "Yanachaga", "Calipuy"))


Download spatial data of Peru

Description

Downloads spatial data of Peru using Geodetic reference system "WGRS84" and CRS(4326).

Usage

get_geo_peru(
  geography = "all",
  level = "all",
  simplified = TRUE,
  showProgress = TRUE
)

Arguments

geography

A character or a vector with the name of geographical region. An exception is "all" to request all Peru data.

level

A character: "all" for national level data, "dep" for department level data, and "prov" for provincial level data.

simplified

A logical TRUE or FALSE, to select data with all districts or a polygon simplified to a higher level.

showProgress

Logical TRUE or FALSE to display a progress bar during download.

Value

An ⁠"sf" "data.frame"⁠ object containing the spatial data of Peru.

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("CALCA"),
                   level = "prov",
                   simplified = FALSE)

# Read department level data
cusco <- get_geo_peru(geography = "cusco",
                      level = "dep",
                      simplified = TRUE)


Load geopackage from tempdir to global environment

Description

Load geopackage from tempdir to global environment

Usage

load_gpkg(temps = NULL)

Arguments

temps

The address of a gpkg file stored in tempdir. Defaults to NULL


Distritos Peru

Description

Información geográfica vectorial de los 1722 distritos del PERU y su geometría.

Usage

peru

Format

A SpatialPolygonsDataFrame

Source

https://ide.inei.gob.pe/


Select data level: nacional, departamental, provincial

Description

Select data level: nacional, departamental, provincial

Usage

select_data_level(temp_meta, level = "prov")

Arguments

temp_meta

A dataframe with the file_url addresses of perugpkg datasets

level

'all', 'dep' or 'prov'


Select data type: 'original' or 'simplified' (default)

Description

Select data type: 'original' or 'simplified' (default)

Usage

select_data_type(temp_meta, simplified = NULL)

Arguments

temp_meta

A dataframe with the file_url addresses of perugpkg datasets

simplified

Logical TRUE or FALSE indicating whether the function returns the 'original' dataset with high resolution or a dataset with 'simplified' borders (Defaults to TRUE)


Select metadata

Description

Select metadata

Usage

select_metadata(geography, level = "all", simplified = NULL)

Arguments

geography

Which geography will be downloaded.

simplified

Logical TRUE or FALSE indicating whether the function returns the 'original' dataset with high resolution or a dataset with 'simplified' borders (Defaults to TRUE).


Select metadata of anp

Description

Select metadata of anp

Usage

select_metadata_anp(anp)

Arguments

anp

Which anp will be downloaded.