Jakub Nowosad, https://jakubnowosad.com/

FOSS4G Europe 2024, Tartu, Estonia

2024-07-04

“A spatial pattern is a scale-dependent predictability of the physical arrangement of observations” (Dale, 2000)

Main reasons for comparing spatial patterns in rasters (Long and Robertson (2018)):

- Study of change
- Study of similarity
- Study of association
- Spatial model assessment

Types of operations:

- Comparing the same variable(s) for different areas
- Comparing different datasets (e.g., different sensors)
- Comparing the same area but at different times

*NDVI values derived from Sentinel-2 images for early summer:*

*CORINE Land Cover:*

**Advantages:** uses the human ability to recognize patterns and considers many aspects, including local and global similarities, and logical coherence (Hagen-Zanker, 2008).

**Disadvantages:** the observer’s perspective and the chosen visualization method can heavily influence the results (a subjective process). Also, it can be time-consuming and not suitable for large datasets.

**Data type:**continuous, categorical

**Data type:**continuous, categorical**Outcome:**raster, single value, multiple values

*raster outcome:*

*single value outcome:* 0.21

*multiple values outcome:*

**Data type:**continuous, categorical**Outcome:**raster, single value, multiple values**Context:**non-spatial, spatial

**Data type:**continuous, categorical**Outcome:**raster, single value, multiple values**Context:**non-spatial, spatial**Disjoint areas:**no, yes

*Continuous raster data:*

*Categorical raster data:*

*Continuous raster data:*

*Categorical raster data:*

*Continuous raster data:*

method | R package |
---|---|

Spatial autocorrelation of the differences | terra |

Correlation coefficient between focal regions | terra |

Difference in GLCM metrics (Haralick et al., 1973) | GLCMTextures |

Focal difference in surface metrics | geodiv |

Structural similarity index (Robertson et al., 2014; Wang et al., 2004) | SSIMmap |

Comparison of Rao’s quadratic entropy (Rao 1982) | rasterdiv |

*Categorical raster data:*

method | R package |
---|---|

The binary difference between two rasters | terra |

Focal differences of a landscape metric | landscapemetrics |

Cross-entropy loss function | spatialEco |

Dissimilarity between spatial signatures of focal regions of two rasters | motifwm |

*Non-disjoint areas*

method | R package |
---|---|

Root mean square error | yardstick |

Mean absolute difference | diffeR |

Average of Structural Similarity Index | SSIMmap |

**RMSE**: 0.219

**MAD**: 0.184

**SSIM**: 0.638

*Non-disjoint areas*

method | R package |
---|---|

The proportion of changed pixels | terra |

The overall comparison (Pontius 2002) | terra |

Statistics of the differences between rasters’ values | diffeR |

Spatial association between regionalizations (Nowosad and Stepinski 2018) | sabre |

**Proportion of changed pixels**: 0.054

**Overall comparison**: 0.972

**Overall exchange difference**: 5280

**V-measure**: 0.772

0.037 <- **Disimilarity between the distributions** -> 0.028

0.069 <- **Difference in roughness (focal)** -> 0.008

0.019 <- **GLCM** -> 0.004

1.5402113^{4} <- **Difference in Gao’s entropy** -> 1.0611691^{4}

*Disjoint areas*

method | R package |
---|---|

Disimilarity between the distributions | philentropy |

The difference between average of a focal measure | geodiv |

The difference between average of a focal measure | GLCMTextures |

Comparison of the values of the Boltzmann entropy (Gao and Li 2019) | bespatial |

0.036 <- **Difference of SHDI** -> 0.03

0.17 <- **Difference of ED** -> 5.632

0.001 <- **Difference of Zhao’s entropy** -> 0.002

0.001 <- **JS divergence of the spatial signatures** -> 0.083

*Disjoint areas*

method | R package |
---|---|

Comparison of the values of a landscape metric | landscapemetrics |

Comparison of the values of Zhao’s entropy (Zhao and Zhang 2019) | bespatial |

Dissimilarity of a spatial signature (Jasiewicz and Stepinski 2013) | motif |

method | R package |
---|---|

The distribution of the difference between values of two rasters | terra |

Statistics of the differences between rasters’ values calculated at many scales | waywiser |

```
1 2 3 4 6 7
1 4821 357 2 10 0 0
2 1342 67915 684 389 0 0
3 59 415 33670 2896 9 22
4 122 638 1435 7040 229 24
6 0 3 13 20 2177 37
7 0 0 0 0 3 1995
```

method | R package |
---|---|

The contingency table of the values of two rasters | terra |

The above methods can be extended to compare two sets of raster layers, such as two time-series:

- Treat each layer as a separate raster and compare corresponding layers using the methods described above (a pairwise comparison)
- Compress the data into one dimension (e.g., one raster layer) and then compare such compressed data
- Create temporal or spatiotemporal signatures and compare them using dissimilarity measures

Author: Lorena Abad

**R and its packages provide a wide range of tools for comparing spatial patterns**

Remaining issues:

- The current R efforts are rather fragmented, with packages having different interfaces, assumptions, and types of data they can handle
- Not all commonly used methods are implemented in R, e.g., the Complex Wavelet Structural Similarity Index or the Fuzzy Kappa index
- Several packages are not on CRAN, and have minimal documentation and examples
- The efforts needed to develop user tutorials and maintain scientific software are still underappreciated in the scientific community and undervalued in the academic reward system

There is almost an unlimited range of possible map comparison methods, and no universal method for assessing the similarity between spatial patterns (Hagen-Zanker, 2008)

The choice of method should depend on (Boots and Csillag, 2006):

- the pattern characteristics to be examined
- the categories/ranges of values involved in the comparison
- the selection of geographic space
- the choice of the unit of computed measures
- the decision if the significance tests are needed

Other considerations include data preprocessing and the scale and extent of comparison (Tewkesbury et al., 2015)

Different methods can produce varying outcomes when analyzing differences in spatial patterns, and using a variety of methods may be advisable to gain a comprehensive understanding

Author: Lorena Abad

There is a lack of studies that systematically compare different methods of assessing similarity between spatial patterns, or suggest good practices in their use

The growing number of FOSS tools for spatial raster comparison offers a promising avenue for testing various methods and their application to real-life scenarios

**Comparing spatial patterns is a common task****Methods are available for continuous and categorical raster data; can result in raster, single value, or multiple values; can use non-spatial or spatial context; and some can involve disjoint areas****Method selection depends on data and research goals****R packages offer diverse tools for this task****FOSS tools provide opportunities for testing methods****More research needed on method performance and best practices**

Mastodon: fosstodon.org/@nowosad

Website: https://jakubnowosad.com

*Tomasz Stepinski, Maximilian H.K. Hesselbarth, Michael Mahoney, Lorena Abad, and Tarmo K. Remmel for their insightful suggestions*

*The members of the online community for their helpful recommendations regarding R packages for comparing spatial patterns*