get_midagri_data {geoidep}R Documentation

Download Geographic Information from MIDAGRI

Description

This function allows you to download the latest version of MIDAGRI geographic data. For more information you can visit the following page https://siea.midagri.gob.pe/.

Usage

get_midagri_data(layer = NULL, dsn = NULL, show_progress = TRUE, quiet = TRUE)

Arguments

layer

A string. Specifies the layer to download. Available layers are detailed in the 'Details' section.

dsn

Character. The output filename in .shp or .gpkg format. If not provided, a temporary file will be created.

show_progress

Logical. If TRUE, displays a progress bar during the download.

quiet

Logical. If TRUE, suppresses informational messages.

Details

Available layers are:

Value

An 'sf' object containing the downloaded geographic data.

Examples


library(geoidep)
library(sf)
# Disable the use of S2 geometry for accurate spatial operations
sf_use_s2(use_s2 = FALSE)

# Retrieve the polygon for Coronel Portillo province
coronel_portillo <- get_provinces(show_progress = FALSE) |>
  subset(NOMBPROV == "CORONEL PORTILLO") |>
  st_transform(crs = 32718)

# Download and extract the oil palm layer for Coronel Portillo
oil_palm <- get_midagri_data(
  layer = "oil_palm_areas",
  show_progress = FALSE
) |>
  st_intersection(coronel_portillo)

# Visualize the oil palm layer
plot(st_geometry(oil_palm))


[Package geoidep version 0.3.0 Index]