2024-02-20

Package SpatioTemporalCont

  • Very simple package with a couple of functions
  • calculate_prop for spatial continuity
  • calculate_tempcont for temporal continuity
  • First example using basemap

Spatial continuity

calculate_prop

  • It has 3 arguments:
    • Rast: the spatRaster to use
    • Radius: The radius to consider
    • Vars: The variables to calculate
  • It generates a stack of rasters
Landuse <- terra::unwrap(Landuse_DK)

proportions <- calculate_prop(Rast = Landuse,
                              Radius = 200,
                              Vars = c("dry nature", "Forest"))

calculate_prop Result

Comparison for forest several radius

Comparison with Supercells

  • Lets compare at 2400 radius
Forest <- calculate_prop(Rast = Landuse,
                              Radius = 2400,
                              Vars = c("Forest"))


Forest_Motif <- lsp_signature(Landuse, type = "composition", window = 24, normalization = "pdf", ordered = FALSE)
Forest_Motif = lsp_add_terra(Forest_Motif)
Forest_Motif <- Forest_Motif[[8]]

Results

  • Lost resolution in Supercells (Resolution 2400 vs 100 mts)
  • SpatioTemporalCont has circular buffer, Supercells has 2400 meter window

For polygons only

  • summarise_polygons, three types “Inside”, “Both” or “Outside”

Inside

data(Polygons)
data("Landuse_DK")
Landuse <- terra::unwrap(Landuse_DK)

v <- vect(Polygons, "polygons", crs = terra::crs(Landuse))
Inside <- summarise_polygons(Rast = Landuse, Polygons = v,
                            Vars = c("Agriculture","Forest"))
Agriculture Forest
0.6039312 0.2157248
0.8775385 0.0381538
0.5605780 0.2782512
0.7852426 0.1004881
0.7750973 0.0630350
0.4416529 0.3385124
0.7544332 0.0581369
0.5909091 0.3315508
0.3793361 0.3222678
0.4157738 0.1976190

Both

Both <- summarise_polygons(Rast = Landuse, Polygons = v,
  Vars = c("Agriculture","Forest"), type = "Both", dist = 2000)
Agriculture Forest
0.5737431 0.2219086
0.8118472 0.0516991
0.5648772 0.2850265
0.7654505 0.0939262
0.6760861 0.1029503
0.3280482 0.4328941
0.7600357 0.0705153
0.6030322 0.2091584
0.5709880 0.2491674
0.4565173 0.2167616

Outside

Outside <- summarise_polygons(Rast = Landuse, Polygons = v,
  Vars = c("Agriculture","Forest"), type = "Outside", dist = 2000)
Agriculture Forest
0.5655868 0.2235794
0.7980718 0.0553473
0.5669460 0.2882867
0.7538020 0.0900642
0.6551351 0.1107336
0.2701062 0.4810319
0.7637145 0.0823436
0.6046186 0.1931421
0.6656837 0.2130483
0.4782954 0.2374272

Temporal continuity

calculate_tempcont

data(corine)
corine <- terra::unwrap(corine)

calculate_tempcont (Ordinal data)

  • Ordinal dataset
TempContOrd <- calculate_tempcont(Rast = corine,
                                 Vars = c("Coniferous forest" ,"Mixed forest"))

calculate_tempcont (Time Series data)

  • Numeric dataset, not recomended for unevenly spaced time series.
TempContNum <- calculate_tempcont(Rast = corine,
                                  years = c(1990, 2000, 2006, 2012, 2018),
                                 Vars = c("Coniferous forest" ,"Mixed forest"))

Questions?

Extra functionalities

Save as cloud optimized geotiffs

write_cog(TempContNum, "TempContNum.tif")
terra::writeRaster(TempContNum, "TempContNum2.tif")
file.size("TempContNum.tif")
## [1] 202060
file.size("TempContNum2.tif")
## [1] 710850
  • The file is 3.52 smaller

Example