segmetric

Segmentation Assessment Metrics (segmetric)

CRAN status Software License Software Life Cycle

The segmetric is an open source package that provides a set of metrics for analysis and evaluation of geospatial segmentation. It includes more than 20 metrics used in literature for spatial segmentation assessment (Van Rijsbergen, 1979; Levine and Nazif, 1982; Janssen and Molenaar, 1995; Lucieer and Stein, 2002; Carleer et al., 2005; Moller et al., 2007; van Coillie et al., 2008; Costa et al., 2008; Weidner, 2008; Feitosa et al., 2010; Clinton et al. 2010; Persello and Bruzzone, 2010; Yang et al., 2014; and Zhang et al., 2015).

Installation

# install via CRAN 
install.packages("segmetric")

Development version

To install the development version of segmetric, run the following commands

# load necessary libraries
library(devtools)

install_github("michellepicoli/segmetric")

Usage

Spatial datasets can be loaded using sf objects. To create a segmetric object, use function sm_read():

library(segmetric)

# load example datasets
data("sample_ref_sf", package = "segmetric")
data("sample_seg_sf", package = "segmetric")

# create segmetric object
m <- sm_read(ref_sf = sample_ref_sf, seg_sf = sample_seg_sf)

Plot your data using plot() command:

plot(m)

Segmentation metrics can be computed by function sm_compute(). Use summary() to obtain an overall metric (mean or weighted mean).

# compute AFI metric and summarize it
sm_compute(m, "AFI") %>% summary()
#> [1] -0.007097452

Make multiple calls to compute more other metrics:

# compute OS1, F_measure, and US2 metrics
m <- 
  sm_compute(m, "OS1") %>%
  sm_compute("F_measure") %>%
  sm_compute("US2")

# summarize them
summary(m)
#>        OS1  F_measure        US2 
#> 0.17341468 0.84728616 0.08617454

To see all supported metrics, type ?metric_functions or run:

# list all supported metrics
sm_list_metrics()
#>  [1] "AFI"       "D_index"   "E"         "ED3"       "F_measure" "Fitness"  
#>  [7] "M"         "OMerging"  "OS1"       "OS2"       "OS3"       "PI"       
#> [13] "precision" "QR"        "RAsub"     "RAsuper"   "recall"    "UMerging" 
#> [19] "US1"       "US2"       "US3"

Getting Help

A detailed documentation with examples on how to use each function inside segmetric package can be obtained by typing ?segmetric in R console.

How to contribute?

The segmetric package was implemented based on an extensible architecture. Feel free to contribute by implementing new metrics functions.

  1. Make a project fork.
  2. Edit file R/metric-funs.R implementing the new metric.
  3. Register your metric in .db_registry() function at R/db.R file using sm_reg_metric().
  4. Make a Pull Request on the branch dev.

Acknowledgements

This research was supported by the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation program (Grant agreement No 677140 MIDLAND).

References