| Type: | Package |
| Title: | Download Geographic Data on Various Topics Provided and Managed by the Spatial Data Infrastructure of Peru |
| Version: | 0.4.0 |
| Description: | Provides R users with easy access to official cartographic data from Peru across a range of topics, including society, transport, environment, agriculture, climate, and more. It also includes data from regional government entities and technical-scientific institutions, all managed by Peru's Spatial Data Infrastructure. For more information, please visit: https://www.geoidep.gob.pe/. |
| License: | Apache License (≥ 2) |
| URL: | https://geografo.pe/geoidep/ |
| BugReports: | https://github.com/ambarja/geoidep/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | archive, cli, dplyr, httr2 (≥ 1.0.0), jsonlite, lifecycle, rvest, sf, stats, tidyr, terra, tibble, utils |
| Suggests: | ggplot2, knitr, mapgl, rmarkdown, testthat (≥ 3.2.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-24 16:55:15 UTC; mvcs_dgppvu_ambi |
| Author: | antony barja |
| Maintainer: | antony barja <geografo.pe@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-27 09:10:27 UTC |
geoidep: Download Geographic Data on Various Topics Provided and Managed by the Spatial Data Infrastructure of Peru
Description
Provides R users with easy access to official cartographic data from Peru across a range of topics, including society, transport, environment, agriculture, climate, and more. It also includes data from regional government entities and technical-scientific institutions, all managed by Peru's Spatial Data Infrastructure. For more information, please visit: https://www.geoidep.gob.pe/.
Author(s)
Maintainer: antony barja geografo.pe@gmail.com (ORCID) [copyright holder]
Authors:
antony barja geografo.pe@gmail.com (ORCID) [copyright holder]
See Also
Useful links:
List providers, description, year and link
Description
List the available providers of the geoidep package.
Usage
get_data_sources(query = NULL)
Arguments
query |
A string. Default is NULL. Filter by provider name(s). For valid values use |
Value
A tibble object.
Examples
## Not run:
library(geoidep)
get_data_sources()
## End(Not run)
Download INEI departmental boundaries
Description
Download the latest version of the geometry and ubigeos corresponding to the official political division of the departament boundaries of Peru. For more information, visit INEI Spatial Data Portal.
Usage
get_departaments(
departamento = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
departamento |
Character. Name or names in a vector of the level-1 administrative boundary (department) to query. Case-insensitive. |
dsn |
Character. Directory where the file will be saved. If |
show_progress |
Logical. Show a cli progress bar. Default |
quiet |
Logical. Suppress info message from |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Value
An sf object.
Examples
## Not run:
library(geoidep)
dep <- get_departaments(show_progress = FALSE)
head(dep)
loreto <- get_departaments(departamento = "loreto", show_progress = FALSE)
head(loreto)
## End(Not run)
Download INEI district boundaries
Description
Download the latest version of the geometry and ubigeos corresponding to the official political division of the district boundaries of Peru. For more information, visit INEI Spatial Data Portal.
Usage
get_districts(
departamento = NULL,
provincia = NULL,
distrito = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
departamento |
Character. Level-1 name. Case-insensitive. |
provincia |
Character. Level-2 name. Case-insensitive. |
distrito |
Character. Level-3 name. Case-insensitive. |
dsn |
Character. Directory where the file will be saved. If |
show_progress |
Logical. Show a cli progress bar. |
quiet |
Logical. Suppress info message. |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Details
Value
An sf object.
Examples
## Not run:
library(geoidep)
dist <- get_districts(show_progress = FALSE)
head(dist)
lima <- get_districts(departamento = "lima", provincia = "lima", show_progress = FALSE)
head(lima)
## End(Not run)
Download information on the latest deforestation alerts detected by Geobosque
Description
Download deforestation alert information detected by Geobosque for any polygon in Peru. For more details, visit Geobosque Platform.
Usage
get_early_warning(region, sf = TRUE, show_progress = TRUE)
Arguments
region |
An sf object. Area of interest (must be EPSG:4326). |
sf |
Logical. Return an |
show_progress |
Logical. Show cli progress. Default |
Value
A tibble or sf object.
Examples
## Not run:
library(geoidep)
loreto <- get_departaments(show_progress = FALSE) |> subset(nombdep == "LORETO")
warning_point <- get_early_warning(region = loreto, sf = TRUE, show_progress = FALSE)
head(warning_point)
## End(Not run)
Download the forest and loss information from Geobosque
Description
Download the ubigeos corresponding to the official political division of the district, province or region boundaries of Peru with forest and loss information. For more information, visit Geobosque Platform.
Usage
get_forest_loss_data(layer = NULL, ubigeo = NULL, show_progress = TRUE)
Arguments
layer |
A string. One of |
ubigeo |
A string. Ubigeo code: 6 digits (distrito), 4 digits (provincia), 2 digits (departamento). |
show_progress |
Logical. Show cli progress. Default |
Details
Available layers:
-
stock_bosque_perdida_distrito: forest stock/loss for a district.
-
stock_bosque_perdida_provincia: forest stock/loss for a province.
-
stock_bosque_perdida_departamento: forest stock/loss for a region.
The data come from the wet-forest (bosque humedo) loss series of the
current Geobosques API (years 2001-2025) and are returned with the
historical column layout (anio, perdida, rango1-rango5, ubigeo).
Value
A tibble object.
Examples
## Not run:
library(geoidep)
geobosque <- get_forest_loss_data(
layer = "stock_bosque_perdida_distrito",
ubigeo = "010101",
show_progress = FALSE)
head(geobosque)
## End(Not run)
Download available hot spot data from Serfor's Satellite Monitoring Unit
Description
Download the latest version of forest fire data available from the Satellite Monitoring Unit of the National Forestry and Wildlife Service of Peru. For more information, visit Serfor Platform.
Usage
get_hotspots_data(dsn = NULL, show_progress = TRUE, quiet = TRUE)
Arguments
dsn |
Character. Output filename. If missing, a temporary file is created. |
show_progress |
Logical. Show a cli progress bar. Default |
quiet |
Logical. Suppress message from |
Value
An sf object.
Examples
## Not run:
library(geoidep)
library(sf)
hot_spots <- get_hotspots_data(show_progress = FALSE)
head(hot_spots)
## End(Not run)
Download the available data from INAIGEM
Description
Download the latest version of data available on the INAIGEM geoportal. For more information, visit INAIGEM Geoportal.
Usage
get_inaigem_data(
layer = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
layer |
Select only one from the list of available layers, for more information please use |
dsn |
Character. Output filename. If missing, a temporary file is created. |
show_progress |
Logical. Show a cli progress bar. Default |
quiet |
Logical. Suppress info message. Default |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Value
An sf object.
Examples
## Not run:
library(geoidep)
library(sf)
glaciar <- get_inaigem_data(layer = "glaciares_1989", show_progress = FALSE)
head(glaciar)
plot(st_geometry(glaciar))
## End(Not run)
Download before/after deforestation images from MapBiomas Alerta Peru
Description
Download satellite imagery (before/after deforestation) for specific MapBiomas Alerta alerts from public Google Cloud Storage buckets. Progress uses cli.
Usage
get_mapbiomas_alert_images(
alert_ids,
download_dir = NULL,
image_type = "both",
show_progress = TRUE,
overwrite = FALSE
)
Arguments
alert_ids |
Character or numeric vector. Alert IDs to download images for. |
download_dir |
Character. Directory where images will be saved. If NULL, a temporary directory is used. |
image_type |
Character. Which images to download: "both" (default), "before", or "after". |
show_progress |
Logical. Show cli progress. Default |
overwrite |
Logical. Overwrite existing files. Default |
Details
File names follow the pattern alert_{id}_before_deforestation.png and
alert_{id}_after_deforestation.png. Each image has a 120-second timeout.
Value
A tibble with columns alert_id, image_type, url, local_path, status, error_message.
Examples
## Not run:
library(geoidep)
aoi <- get_departaments(show_progress = FALSE) |>
subset(nombdep == "UCAYALI")
alerts <- get_mapbiomas_peru_alerta(region = aoi, show_progress = FALSE)
alert_ids <- alerts$id[1:5]
download_dir <- file.path(tempdir(), "mapbiomas_images")
results <- get_mapbiomas_alert_images(
alert_ids = alert_ids,
download_dir = download_dir,
show_progress = FALSE
)
head(results)
## End(Not run)
Download MapBiomas Alerta Peru deforestation alerts with spatial filtering
Description
Download the latest deforestation alerts detected by MapBiomas Alerta Peru for a specific geographic area using an sf object (bounding box or polygon). For more details, please visit: MapBiomas Alerta Platform
Usage
get_mapbiomas_peru_alerta(
region = NULL,
from = NULL,
to = NULL,
dsn = NULL,
method = "within",
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
region |
An sf object specifying the area of interest (must be in EPSG:4326 - WGS 84). |
from |
Character. Start date in |
to |
Character. End date in |
dsn |
Character. Output filename. If missing, a temporary GeoJSON file is created. |
method |
Character. Spatial predicate used to filter the downloaded alerts against |
show_progress |
Logical. Show cli progress. Default |
quiet |
Logical. Suppress messages from |
timeout |
Numeric. Seconds to wait for the server response (default 60). |
Details
The bounding box of region is used to query the WFS service. Image URLs
are generated from the alert id and point to public Google Cloud Storage buckets.
Column names are normalised to lowercase.
Value
An sf object with alert geometries, attributes and image URLs.
Get a MapBiomas Peru Fire raster
Description
Lazily reads a MapBiomas Fuego (Fire) Peru raster from a given
sub-product, hosted as a GeoTIFF on Google Cloud Storage. Only the bytes
required for the requested extent are downloaded (via GDAL's
/vsicurl/ driver). Optionally crops and masks the raster to an
area of interest.
Usage
get_mapbiomas_peru_fire(product, year, crop_to = NULL, collection = 1)
Arguments
product |
Character. One of the products listed in
|
year |
Integer. For |
crop_to |
Optional. An |
collection |
Integer. MapBiomas Fuego Peru collection. Default |
Value
A SpatRaster with one layer.
Examples
## Not run:
library(geoidep)
lima <- get_departaments("LIMA")
burned_2024 <- get_mapbiomas_peru_fire(product = "annual_burned", year = 2024, crop_to = lima)
## End(Not run)
Get the MapBiomas Peru Fire legend for a given product
Description
Returns a lookup table with the pixel value codes, English/Spanish class
names, and hexadecimal colors used by a given MapBiomas Fuego Peru
sub-product (Collection 1). Useful for building color scales (see
scale_fill_mapbiomas_peru_fire_d).
Usage
get_mapbiomas_peru_fire_legend(product)
Arguments
product |
Character. One of the products listed in
|
Details
-
annual_burnedandaccumulated_burned: binary classification (1 = "Burned area"). -
annual_burned_coverageandaccumulated_burned_coverage: share the LULC legend. -
monthly_burned: values1-12= month of burning. -
frequency_burned: values1-12= burn count (12= "12 or more times"). -
year_last_fire: values are years (2013-2024). -
annual_burned_scar_size_range: values1-5= scar size class.
Value
A tibble with columns id, class_en, class_es, and hex.
Examples
library(geoidep)
get_mapbiomas_peru_fire_legend("frequency_burned")
Get available MapBiomas Peru Fire products
Description
Returns a lookup table describing the MapBiomas Fuego (Fire) Peru
sub-products available for download, including their internal codes,
descriptions, and whether they are indexed by a single year or by
a year range (starting in 2013).
Usage
get_mapbiomas_peru_fire_products()
Value
A tibble with columns product, description_en,
description_es, and temporal ("annual" or "range").
Examples
library(geoidep)
get_mapbiomas_peru_fire_products()
Get MapBiomas Peru land use / land cover raster
Description
Lazily reads a single-year Land Use and Land Cover (LULC) classification
raster from the MapBiomas Peru collection. Only the bytes required for the
requested extent are downloaded (via GDAL's /vsicurl/ driver).
Optionally crops and masks the raster to an area of interest.
Usage
get_mapbiomas_peru_lulc(year, crop_to = NULL, collection = 4)
Arguments
year |
Integer. Year of the classification (e.g. |
crop_to |
Optional. An |
collection |
Integer. MapBiomas Peru collection number ( |
Value
A SpatRaster with one layer named classification_<year>.
Examples
## Not run:
library(geoidep)
lima <- get_departaments("LIMA", show_progress = FALSE)
lulc_2024 <- get_mapbiomas_peru_lulc(year = 2024, crop_to = lima)
lulc_2024
lulc_2025 <- get_mapbiomas_peru_lulc(year = 2025, collection = 4, crop_to = lima)
lulc_2025
## End(Not run)
Get a multi-year stack of MapBiomas Peru LULC rasters
Description
Downloads and stacks multiple single-year LULC rasters from MapBiomas
Peru (see get_mapbiomas_peru_lulc), each cropped to the same
area of interest if provided. Progress uses cli.
Usage
get_mapbiomas_peru_lulc_series(
years,
crop_to = NULL,
collection = 4,
show_progress = TRUE
)
Arguments
years |
Integer vector. Years to download (e.g. |
crop_to |
Optional. An |
collection |
Integer. MapBiomas Peru collection number ( |
show_progress |
Logical. Show a cli progress bar. Default |
Value
A SpatRaster with one layer per year, named classification_<year>.
Examples
## Not run:
library(geoidep)
lima <- get_departaments("LIMA", show_progress = FALSE)
lulc_series <- get_mapbiomas_peru_lulc_series(years = 2020:2024, crop_to = lima)
lulc_series
## End(Not run)
Download the available data from MTC
Description
Download the latest version of data available on the MTC geoportal. For more information, visit MTC Geoportal.
Usage
get_mtc_data(
layer = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
layer |
Select only one from the list of available layers, for more information please use |
dsn |
Character. Output filename with the spatial format. If missing, a temporary file is created. |
show_progress |
Logical. Show a cli progress bar. Default |
quiet |
Logical. Suppress info message. Default |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Value
An sf object.
Examples
## Not run:
library(geoidep)
library(sf)
aerodromo <- get_mtc_data(layer = "aerodromos_2023", show_progress = FALSE)
head(aerodromo)
plot(st_geometry(aerodromo))
## End(Not run)
List resources and count layers of IDEP
Description
Summary of providers.
Usage
get_providers(query = NULL)
Arguments
query |
Character. Default is NULL (only |
Value
A tibble with columns provider and layer_count.
Examples
## Not run:
library(geoidep)
get_providers()
## End(Not run)
Download INEI province boundaries
Description
Download the latest version of the geometry and ubigeos corresponding to the official political division of the province boundaries of Peru. For more information, visit INEI Spatial Data Portal.
Usage
get_provinces(
departamento = NULL,
provincia = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
departamento |
Character. Name of the level-1 administrative boundary (department). Case-insensitive. |
provincia |
Character. Name of the level-2 administrative boundary (province). Case-insensitive. Requires |
dsn |
Character. Directory where the file will be saved. If |
show_progress |
Logical. Show a cli progress bar. |
quiet |
Logical. Suppress info message. |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Value
An sf object.
Examples
## Not run:
library(geoidep)
prov <- get_provinces(show_progress = FALSE)
head(prov)
## End(Not run)
Download the available data from Sernanp
Description
Download the latest version of data available on the sernanp geoviewer. For more information, visit Sernanp Platform.
Usage
get_sernanp_data(
layer = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
layer |
Select only one from the list of available layers, for more information please use |
dsn |
Character. Output filename. If missing, a temporary file is created. |
show_progress |
Logical. Show a cli progress bar. Default |
quiet |
Logical. Suppress info message. Default |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Value
An sf object.
Examples
## Not run:
library(geoidep)
library(sf)
anp <- get_sernanp_data(layer = "zonificacion_anp", show_progress = FALSE)
plot(st_geometry(anp))
## End(Not run)
Discrete fill scale for MapBiomas Peru Fire products
Description
A ggplot2 discrete fill scale that applies the official
MapBiomas Fuego Peru (Collection 1) color palette for a given sub-product
to a classified SpatRaster (as a factor), for use with
tidyterra::geom_spatraster().
Usage
scale_fill_mapbiomas_peru_fire_d(
product,
...,
lang = c("en", "es"),
na.translate = FALSE
)
Arguments
product |
Character. One of the products listed in
|
... |
Additional arguments passed to |
lang |
Character. Legend language, either |
na.translate |
Logical. Should |
Value
A ggplot2 discrete scale object.
Examples
## Not run:
library(geoidep)
library(ggplot2)
library(tidyterra)
lima <- get_departaments("LIMA", show_progress = FALSE)
freq <- get_mapbiomas_peru_fire(product = "frequency_burned", year = 2024, crop_to = lima)
ggplot() +
geom_spatraster(data = as.factor(freq)) +
scale_fill_mapbiomas_peru_fire_d("frequency_burned", lang = "es") +
theme_minimal()
## End(Not run)
Discrete fill scale for MapBiomas Peru LULC classes
Description
A ggplot2 discrete fill scale that applies the official MapBiomas
Peru Collection 3 color palette to a classified SpatRaster (as a
factor), for use with tidyterra::geom_spatraster().
Usage
scale_fill_mapbiomas_peru_lulc_d(
...,
lang = c("en", "es"),
na.translate = FALSE
)
Arguments
... |
Additional arguments passed to |
lang |
Character. Legend language, either |
na.translate |
Logical. Should |
Value
A ggplot2 discrete scale object.
Examples
## Not run:
library(geoidep)
library(ggplot2)
library(tidyterra)
lima <- get_departaments("LIMA")
lulc_2024 <- get_mapbiomas_peru_lulc(year = 2024, crop_to = lima)
ggplot() +
geom_spatraster(data = as.factor(lulc_2024)) +
scale_fill_mapbiomas_peru_lulc_d(lang = "es") +
theme_minimal() +
labs(fill = "Cobertura/Uso", title = "MapBiomas Peru 2024")
## End(Not run)
Filter Senamhi alerts by number
Description
Filter Senamhi alerts by number
Usage
senamhi_alert_by_number(data, nro)
Arguments
data |
A data frame of meteorological alerts. |
nro |
A numeric vector indicating the alert number(s). |
Value
A filtered tibble.
Filter Senamhi alerts by year
Description
Filter Senamhi alerts by year
Usage
senamhi_alerts_by_year(data, year)
Arguments
data |
A data frame of meteorological alerts. |
year |
A numeric value indicating the year. |
Value
A filtered tibble.
Filter alert geometry by danger level
Description
This function filters the sf object from Senamhi by alert level (e.g., 1 to 4).
Usage
senamhi_geometry_by_level(sf_data, level)
Arguments
sf_data |
An sf object returned by |
level |
Numeric or character vector: values like 1, 2, 3, 4 or "Nivel 1", etc. |
Value
Filtered sf object.
Examples
## Not run:
senamhi_get_meteorological_table() |>
senamhi_alert_by_number(295) |>
senamhi_alerts_by_year(2024) |>
senamhi_get_spatial_alerts(show_progress = FALSE) |>
senamhi_geometry_by_level(3) |>
plot()
## End(Not run)
Download Weather Alert Table from Senamhi
Description
This function downloads the table of weather warnings provided by Senamhi. For more information, please visit the following link: https://www.senamhi.gob.pe/?&p=aviso-meteorologico
Usage
senamhi_get_meteorological_table(show_progress = TRUE, timeout = 60)
Arguments
show_progress |
Logical. Show a cli progress bar. Default |
timeout |
Numeric. Seconds to wait for the server response. Default 60. |
Value
A tibble object containing the weather alert data.
Examples
## Not run:
data <- senamhi_get_meteorological_table(show_progress = FALSE)
head(data)
## End(Not run)
Download Meteorological Alert Geometry from Senamhi
Description
This function downloads the spatial alert geometry (shapefile) from Senamhi for a given alert.
Usage
senamhi_get_spatial_alerts(
data = NULL,
nro = NULL,
year = NULL,
dsn = NULL,
show_progress = TRUE,
quiet = TRUE,
timeout = 60
)
Arguments
data |
A data frame with a single alert (with columns |
nro |
A numeric value (optional if |
year |
A numeric value (optional if |
dsn |
Path to save the downloaded .zip. If NULL, a temporary file is used. |
show_progress |
Logical, show cli progress bar. |
quiet |
Logical, suppress messages from |
timeout |
Numeric. Seconds to wait for a response. Default 60. |
Value
An sf object with the alert geometry.