Skip to contents

1. Introduction

This package aims to provide R users with a new way of accessing official Peruvian cartographic data on various topics that are managed by the country’s Spatial Data Infrastructure.

By offering a new approach to accessing this official data, both from technical-scientific entities and from regional and local governments, it facilitates the automation of processes, thereby optimizing the analysis and use of geospatial information across various fields.

However, this project is still under construction, for more information you can visit the GitHub official repository https://github.com/ambarja/geoidep.

If you want to support this project, you can support me with a coffee for my programming moments.

2. Package installation

install.packages("geoidep")

Also, you can install the development version as follows:

install.packages('pak')
pak::pkg_install('ambarja/geoidep')

3. Basic usage

providers <- get_data_sources()
providers
#> # A tibble: 76 × 7
#>    provider  category      layer       layer_can_be_actived admin_en year  link 
#>    <chr>     <chr>         <chr>       <lgl>                <chr>    <chr> <chr>
#>  1 INEI      General       departamen… TRUE                 Nationa… 2019  http…
#>  2 INEI      General       provincia   TRUE                 Nationa… 2019  http…
#>  3 INEI      General       distritos   TRUE                 Nationa… 2019  http…
#>  4 Midagri   Agriculture   vegetation… TRUE                 Ministr… 2018  http…
#>  5 Midagri   Agriculture   agricultur… TRUE                 Ministr… 2024  http…
#>  6 Midagri   Agriculture   oil_palm_a… TRUE                 Ministr… 2016… http…
#>  7 Midagri   Institucional experiment… TRUE                 Ministr… 2024  http…
#>  8 Geobosque Forest        stock_bosq… FALSE                Ministr… 2001… http…
#>  9 Geobosque Forest        stock_bosq… TRUE                 Ministr… 2001… http…
#> 10 Geobosque Forest        stock_bosq… TRUE                 Ministr… 2001… http…
#> # ℹ 66 more rows
layers_available <- get_providers()
layers_available
#> # A tibble: 6 × 2
#>   provider  layer_count
#>   <fct>           <int>
#> 1 Geobosque           5
#> 2 INEI                3
#> 3 Midagri             4
#> 4 Senamhi             1
#> 5 Serfor              2
#> 6 Sernanp            61

4. Download Official Administrative Boundaries by INEI

# Region boundaries download 
loreto_prov <- get_provinces(show_progress = FALSE) |> 
  subset(NOMBDEP == 'LORETO')
library(leaflet)
#> 
#> Attaching package: 'leaflet'
#> The following object is masked _by_ '.GlobalEnv':
#> 
#>     providers
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
loreto_prov |> 
  leaflet() |> 
  addTiles() |> 
  addPolygons()