Analyzing forest fires with the geoideo package

1. Introduction

geoidep currently allows you to work with data from Serfor’s Satellite Tracking Unit.

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')
library(geoidep)

3. Filter the available Serfor layer

providers <- get_data_sources(query = "Serfor")
providers
#> # A tibble: 2 × 7
#>   provider category layer       layer_can_be_actived admin_en        year  link 
#>   <chr>    <chr>    <chr>       <lgl>                <chr>           <chr> <chr>
#> 1 Serfor   Hazard   fire_forest TRUE                 Ministry of En… Not … http…
#> 2 Serfor   Hazard   hot_spots   TRUE                 Ministry of En… Not … http…

4. Forest fire data collection download

incendio.forestal <- get_forest_fire_data(show_progress = FALSE)
#> Reading layer `file135a5a1e0f40' from data source 
#>   `/tmp/RtmpQw1o3S/file135a5a1e0f40.geojson' using driver `GeoJSON'
#> Simple feature collection with 2289 features and 34 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -80.31021 ymin: -14.3616 xmax: -72.00732 ymax: -3.94879
#> Geodetic CRS:  WGS 84
head(incendio.forestal)
#> Simple feature collection with 6 features and 34 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -79.86639 ymin: -7.482966 xmax: -78.41394 ymax: -4.67092
#> Geodetic CRS:  WGS 84
#>   OBJECTID                                          FUENTE DOCREG
#> 1   223868 Servicio Nacional Forestal y de Fauna Silvestre       
#> 2   223867 Servicio Nacional Forestal y de Fauna Silvestre       
#> 3   223866 Servicio Nacional Forestal y de Fauna Silvestre       
#> 4   223865 Servicio Nacional Forestal y de Fauna Silvestre       
#> 5   223864 Servicio Nacional Forestal y de Fauna Silvestre       
#> 6   223863 Servicio Nacional Forestal y de Fauna Silvestre       
#>                FECREG
#> 1 2024-11-16 05:00:00
#> 2 2024-11-16 05:00:00
#> 3 2024-11-16 05:00:00
#> 4 2024-11-16 05:00:00
#> 5 2024-11-16 05:00:00
#> 6 2024-11-16 05:00:00
#>                                                                                        OBSERV
#> 1 Información generada por la Unidad Funcional de Monitoreo Satelital de la DGIOFFS de SERFOR
#> 2 Información generada por la Unidad Funcional de Monitoreo Satelital de la DGIOFFS de SERFOR
#> 3 Información generada por la Unidad Funcional de Monitoreo Satelital de la DGIOFFS de SERFOR
#> 4 Información generada por la Unidad Funcional de Monitoreo Satelital de la DGIOFFS de SERFOR
#> 5 Información generada por la Unidad Funcional de Monitoreo Satelital de la DGIOFFS de SERFOR
#> 6 Información generada por la Unidad Funcional de Monitoreo Satelital de la DGIOFFS de SERFOR
#>   ZONUTM ORIGEN    NOMDEP    NOMPRO  NOMDIS   CAPITAL               FECHA
#> 1     17      2 CAJAMARCA CAJAMARCA  COSPAN CAJAMARCA 2024-11-16 05:00:00
#> 2     17      2     PIURA   AYABACA MONTERO   MONTERO 2024-11-15 05:00:00
#> 3     17      2     PIURA   AYABACA MONTERO   MONTERO 2024-11-16 05:00:00
#> 4     17      2     PIURA   AYABACA MONTERO   MONTERO 2024-11-16 05:00:00
#> 5     17      2     PIURA   AYABACA MONTERO   MONTERO 2024-11-16 05:00:00
#> 6     17      2     PIURA   AYABACA MONTERO   MONTERO 2024-11-15 05:00:00
#>       HORA CATEG    NOMCATEG  LATITUD  LONGITUD   COORES  COORNO         CODREP
#> 1 13:30:00     4 Sunchubamba -7.48297 -78.41394 785423.4 9172021 PIF_05304_2024
#> 2 13:42:00    25    LA PALMA -4.67092 -79.86639 625734.4 9483610 PIF_05303_2024
#> 3 14:10:00    25    LA PALMA -4.67265 -79.85905 626548.3 9483418 PIF_05303_2024
#> 4 13:45:00    25    LA PALMA -4.67289 -79.85994 626449.6 9483391 PIF_05303_2024
#> 5 13:21:00    25    LA PALMA -4.67334 -79.85773 626694.6 9483341 PIF_05303_2024
#> 6 14:27:00    25    LA PALMA -4.67344 -79.86076 626358.5 9483331 PIF_05303_2024
#>   created_user        created_date last_edited_user    last_edited_date ESTADO
#> 1   JMONTALBAN 2024-11-17 10:17:50       JMONTALBAN 2024-11-17 10:17:50      1
#> 2   JMONTALBAN 2024-11-17 10:17:50           UFMS17 2024-11-17 10:32:03      2
#> 3   JMONTALBAN 2024-11-17 10:17:50           UFMS17 2024-11-17 10:32:03      2
#> 4   JMONTALBAN 2024-11-17 10:17:50           UFMS17 2024-11-17 10:32:03      2
#> 5   JMONTALBAN 2024-11-17 10:17:50           UFMS17 2024-11-17 10:32:03      2
#> 6   JMONTALBAN 2024-11-17 10:17:50           UFMS17 2024-11-17 10:32:03      2
#>               TIPCOB PELIGRO REFESTADO CONF CODRVIF         SENSAT CATDEP
#> 1 Cobertura Agrícola       0         0    0       0 GOES (16 y 18)     06
#> 2 Cobertura Forestal       0         0    0       0            N21     20
#> 3 Cobertura Forestal       0         0    0       0            N20     20
#> 4 Cobertura Forestal       0         0    0       0              N     20
#> 5 Cobertura Forestal       0         0    0       0            N21     20
#> 6 Cobertura Forestal       0         0    0       0            N20     20
#>   CATPRO CATDIS                    geometry
#> 1   0601 060104 POINT (-78.41394 -7.482966)
#> 2   2002 200205  POINT (-79.86639 -4.67092)
#> 3   2002 200205  POINT (-79.85905 -4.67265)
#> 4   2002 200205  POINT (-79.85994 -4.67289)
#> 5   2002 200205  POINT (-79.85773 -4.67334)
#> 6   2002 200205  POINT (-79.86076 -4.67344)

5. National Forest Fire Count

library(sf)
library(dplyr)
library(ggplot2)
stats <- incendio.forestal |> 
  st_drop_geometry() |>
  filter(FECHA >= '2024-09-11') |> 
  group_by(NOMDEP) |> 
  summarise( total = n()) 
# Simple visualisation
stats |> 
  ggplot(aes(x = NOMDEP, y = total)) + 
  geom_bar(stat = "identity") + 
  coord_polar() + 
  theme_minimal(base_size = 10)  + 
  labs(x="", y = "", caption = "Unidad de Monitoreo Forestales - SERFOR")

6. Download the official INEI administrative limits of interest

# Region boundaries download 
ucayali_dep <- get_departaments(show_progress = FALSE) |> 
  subset(NOMBDEP == 'UCAYALI')
# The first five rows
head(ucayali_dep)
#> Simple feature collection with 1 feature and 6 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -75.94789 ymin: -11.44834 xmax: -70.49442 ymax: -7.262049
#> Geodetic CRS:  WGS 84
#>    id OBJECTID CCDD NOMBDEP SHAPE_Length SHAPE_Area
#> 24 24       24   25 UCAYALI     27.47016   8.660111
#>                              geom
#> 24 MULTIPOLYGON (((-74.47145 -...

7. Forest fire count in the area of interest only

# Data collection only within the regions of interest.
ucayali.if <- st_filter(incendio.forestal, ucayali_dep)
head(ucayali.if)
#> Simple feature collection with 0 features and 34 fields
#> Bounding box:  xmin: NA ymin: NA xmax: NA ymax: NA
#> Geodetic CRS:  WGS 84
#>  [1] OBJECTID         FUENTE           DOCREG           FECREG          
#>  [5] OBSERV           ZONUTM           ORIGEN           NOMDEP          
#>  [9] NOMPRO           NOMDIS           CAPITAL          FECHA           
#> [13] HORA             CATEG            NOMCATEG         LATITUD         
#> [17] LONGITUD         COORES           COORNO           CODREP          
#> [21] created_user     created_date     last_edited_user last_edited_date
#> [25] ESTADO           TIPCOB           PELIGRO          REFESTADO       
#> [29] CONF             CODRVIF          SENSAT           CATDEP          
#> [33] CATPRO           CATDIS           geometry        
#> <0 rows> (or 0-length row.names)

8. Simple visualization with leaflet

library(leaflet)
#> 
#> Attaching package: 'leaflet'
#> The following object is masked _by_ '.GlobalEnv':
#> 
#>     providers
library(leaflet.extras)
ucayali.if |> 
  leaflet() |> 
  addProviderTiles(provider = "CartoDB.Positron") |> 
  addHeatmap(radius = 10,minOpacity = 1)