Learn R Programming

motif

The motif package implements and extends ideas of the pattern-based spatial analysis in R. It describes spatial patterns of categorical raster data for any defined regular and irregular areas. Patterns are represented quantitatively using built-in signatures based on co-occurrence matrices but also allows for any user-defined functions. It enables spatial analysis such as search, change detection, and clustering to be performed on spatial patterns.

Installation

You can install the released version of motif from CRAN with:

install.packages("motif")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("Nowosad/motif")

Documentation

See the package’s vignettes:

  1. Introduction to the motif package
  2. Types of spatial patterns’ signatures
  3. Spatial patterns’ search
  4. Spatial patterns’ comparision
  5. Spatial patterns’ clustering
  6. Extracting the proportion of different classes in many regular local landscapes

Contribution

Contributions to this package are welcome. The preferred method of contribution is through a GitHub pull request. Feel free to contact us by creating an issue.

Citation

To cite the motif package in publications, please use this paper:

Nowosad, J. Motif: an open-source R tool for pattern-based spatial analysis. Landscape Ecol (2021). https://doi.org/10.1007/s10980-020-01135-0

LaTeX/BibTeX version can be obtained with:

library(motif)
citation("motif")

Copy Link

Version

Install

install.packages('motif')

Monthly Downloads

419

Version

0.6.5

License

MIT + file LICENSE

Maintainer

Jakub Nowosad

Last Published

July 26th, 2025

Functions in motif (0.6.5)

lsp_transform

Transforms lsp objects
prepare_window

Prepares window* arguments (internal function)
lsp_search

Search for similar spatial pattern
motif-package

motif: Local Pattern Analysis
lsp_add_sf

Creates or adds a sf object
lsp_add_stars

Creates or adds a stars object
determine_classes

Determine unique classes (internal function)
lsp_compare

Comparison between spatial patterns
lsp_add_clusters

Adds clusters' ids to a lsp object
lsp_add_examples

Adds spatial data of each region in an lsp or sf object
lsp_mosaic

Creates a raster mosaic
lsp_extract

Extracts a local landscape
lsp_add_terra

Creates or adds a terra object
lsp_add_quality

Calculates quality metrics of clustering or segmentation
lsp_signature

Creates a spatial signature
lsp_restructure

Changes structure of the lsp object
lsp_to_dist

Calculate Distance Matrix