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 `file1206607e074f' from data source 
#>   `/tmp/RtmpTlnBuI/file1206607e074f.geojson' using driver `GeoJSON'
#> Simple feature collection with 218 features and 34 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -80.30985 ymin: -6.29864 xmax: -78.43745 ymax: -3.63648
#> Geodetic CRS:  WGS 84
head(incendio.forestal)
#> Simple feature collection with 6 features and 34 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -80.30985 ymin: -4.482593 xmax: -79.86921 ymax: -3.638177
#> Geodetic CRS:  WGS 84
#>   OBJECTID                                          FUENTE DOCREG
#> 1   225866 Servicio Nacional Forestal y de Fauna Silvestre       
#> 2   225865 Servicio Nacional Forestal y de Fauna Silvestre       
#> 3   225864 Servicio Nacional Forestal y de Fauna Silvestre       
#> 4   225863 Servicio Nacional Forestal y de Fauna Silvestre       
#> 5   225862 Servicio Nacional Forestal y de Fauna Silvestre       
#> 6   225861 Servicio Nacional Forestal y de Fauna Silvestre       
#>                FECREG
#> 1 2024-11-22 05:00:00
#> 2 2024-11-22 05:00:00
#> 3 2024-11-22 05:00:00
#> 4 2024-11-22 05:00:00
#> 5 2024-11-22 05:00:00
#> 6 2024-11-22 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
#> 1     17      2  PIURA   AYABACA             JILILI            AYABACA
#> 2     17      2 TUMBES    TUMBES PAMPAS DE HOSPITAL             TUMBES
#> 3     17      2 TUMBES    TUMBES PAMPAS DE HOSPITAL PAMPAS DE HOSPITAL
#> 4     17      2 TUMBES    TUMBES PAMPAS DE HOSPITAL PAMPAS DE HOSPITAL
#> 5     17      2 TUMBES    TUMBES PAMPAS DE HOSPITAL PAMPAS DE HOSPITAL
#> 6     17      2 TUMBES ZARUMILLA           MATAPALO          ZARUMILLA
#>                 FECHA     HORA CATEG  NOMCATEG  LATITUD  LONGITUD   COORES
#> 1 2024-11-22 05:00:00 11:00:00    30           -4.48259 -79.86921 625454.2
#> 2 2024-11-22 05:00:00 13:50:00     3 de Tumbes -4.01547 -80.30040 577659.7
#> 3 2024-11-22 05:00:00 13:55:00     3 de Tumbes -3.91692 -80.24283 584061.0
#> 4 2024-11-22 05:00:00 13:55:00     3 de Tumbes -3.91942 -80.24200 584152.9
#> 5 2024-11-22 05:00:00 13:55:00     3 de Tumbes -3.99901 -80.30985 576612.5
#> 6 2024-11-22 05:00:00 13:10:00    13      PN05 -3.63818 -80.21057 587670.5
#>    COORNO         CODREP created_user        created_date last_edited_user
#> 1 9504432 PIF_05435_2024   JMONTALBAN 2024-11-23 07:58:56       JMONTALBAN
#> 2 9556129 PIF_05440_2024   JMONTALBAN 2024-11-23 05:18:05       JMONTALBAN
#> 3 9567018 PIF_05439_2024   JMONTALBAN 2024-11-23 05:18:05       JMONTALBAN
#> 4 9566741 PIF_05439_2024   JMONTALBAN 2024-11-23 05:18:05       JMONTALBAN
#> 5 9557950 PIF_05438_2024   JMONTALBAN 2024-11-23 05:18:05       JMONTALBAN
#> 6 9597828 PIF_05437_2024   JMONTALBAN 2024-11-23 05:18:05       JMONTALBAN
#>      last_edited_date ESTADO             TIPCOB PELIGRO REFESTADO CONF CODRVIF
#> 1 2024-11-23 07:58:56      1 Cobertura Forestal       0         0    0       0
#> 2 2024-11-23 05:18:05      1 Cobertura Forestal       0         0    0       0
#> 3 2024-11-23 05:18:05      1 Cobertura Forestal       0         0    0       0
#> 4 2024-11-23 05:18:05      1 Cobertura Forestal       0         0    0       0
#> 5 2024-11-23 05:18:05      1 Cobertura Forestal       0         0    0       0
#> 6 2024-11-23 05:18:05      1 Cobertura Forestal       0         0    0       0
#>           SENSAT CATDEP CATPRO CATDIS                    geometry
#> 1 GOES (16 y 18)     20   2002 200203 POINT (-79.86921 -4.482593)
#> 2 GOES (16 y 18)     24   2401 240104  POINT (-80.3004 -4.015469)
#> 3            N20     24   2401 240104  POINT (-80.24283 -3.91692)
#> 4            N20     24   2401 240104    POINT (-80.242 -3.91942)
#> 5            N20     24   2401 240104  POINT (-80.30985 -3.99901)
#> 6 GOES (16 y 18)     24   2403 240303 POINT (-80.21057 -3.638177)

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)