This function allows you to download the latest version of MIDAGRI geographic data. For more information you can visit the following page Midagri Platform.
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
Note: . This function is experimental and its API may change in future versions.
Available layers are:
agriculture_sector: Polygons representing the new national register of agricultural statistical sectors for the year 2024.
oil_palm_areas: Polygons representing areas cultivated with oil palm in Peru for the period 2016 to 2020.
Examples
# \donttest{
library(geoidep)
library(sf)
# Disable the use of S2 geometry for accurate spatial operations
sf_use_s2(use_s2 = FALSE)
#> Spherical geometry (s2) switched off
# Retrieve the polygon for Coronel Portillo province
coronel_portillo <- get_provinces(show_progress = FALSE)
names(coronel_portillo)
#> [1] "id" "objectid" "ccdd" "ccpp" "nombdep"
#> [6] "nombprov" "shape_length" "shape_area" "geom"
roi <- coronel_portillo |>
subset(nombprov == "CORONEL PORTILLO") |>
st_transform(crs = 32718)
oil_palm_areas <- get_midagri_data(layer = "oil_palm_areas", show_progress = FALSE) |>
st_intersection(roi)
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
head(oil_palm_areas)
#> Simple feature collection with 6 features and 11 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 493306.5 ymin: 9088071 xmax: 512077.7 ymax: 9106609
#> Projected CRS: WGS 84 / UTM zone 18S
#> Area_ha Fecha ID id objectid ccdd ccpp nombdep nombprov
#> 1153 1.251994689 2018 1153 191 191 25 01 UCAYALI CORONEL PORTILLO
#> 1154 0.480333935 2018 1154 191 191 25 01 UCAYALI CORONEL PORTILLO
#> 1155 0.007059493 2018 1155 191 191 25 01 UCAYALI CORONEL PORTILLO
#> 1156 4.339065218 2018 1156 191 191 25 01 UCAYALI CORONEL PORTILLO
#> 1157 0.254746310 2018 1157 191 191 25 01 UCAYALI CORONEL PORTILLO
#> 1158 1.959960062 2018 1158 191 191 25 01 UCAYALI CORONEL PORTILLO
#> shape_length shape_area geometry
#> 1153 12.79225 3.157117 POLYGON ((494177.3 9088348,...
#> 1154 12.79225 3.157117 POLYGON ((493646.9 9088369,...
#> 1155 12.79225 3.157117 POLYGON ((493306.5 9088071,...
#> 1156 12.79225 3.157117 POLYGON ((507756.7 9102683,...
#> 1157 12.79225 3.157117 POLYGON ((512077.7 9106359,...
#> 1158 12.79225 3.157117 POLYGON ((511688.8 9106562,...
plot(st_geometry(oil_palm_areas))
# }