Title: | Metrics for Assessing Segmentation Accuracy for Geospatial Data |
---|---|
Description: | A system that computes metrics to assess the segmentation accuracy of geospatial data. These metrics calculate the discrepancy between segmented and reference objects, and indicate the segmentation accuracy. For more details on choosing evaluation metrics, we suggest seeing Costa et al. (2018) <doi:10.1016/j.rse.2017.11.024> and Jozdani et al. (2020) <doi:10.1016/j.isprsjprs.2020.01.002>. |
Authors: | Rolf Simoes [aut] |
Maintainer: | Michelle Picoli <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2025-02-16 05:01:39 UTC |
Source: | https://github.com/michellepicoli/segmetric |
Metrics for assessing segmentation accuracy for geospatial data.
The segmetric
package provides a set of metrics for the
segmentation accuracy assessment (or evaluation) of geospatial data.
It includes more than 20 metrics used in the 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).
The segmetric
package is extensible and provides a set of functions to
ease the implementation of new metrics. See ?sm_reg_metric()
to find how
new metrics are implemented.
Contribution to this package could be done at segmetric
's page on GitHub:
https://github.com/michellepicoli/segmetric.
Maintainer: Michelle Picoli [email protected] (ORCID)
Authors:
Rolf Simoes [email protected] (ORCID)
Alber Sanchez [email protected] (ORCID)
Carleer, A.P., Debeir, O., Wolff, E., 2005. Assessment of very high spatial resolution satellite image segmentations. Photogramm. Eng. Remote. Sens. 71, 1285-1294. doi:10.14358/PERS.71.11.1285.
Clinton, N., Holt, A., Scarborough, J., Yan, L., Gong, P., 2010. Accuracy assessment measures for object-based image segmentation goodness. Photogramm. Eng. Remote. Sens. 76, pp. 289-299.
Costa, G.A.O.P., Feitosa, R.Q., Cazes, T.B., Feijo, B., 2008. Genetic adaptation of segmentation parameters. In: Blaschke, T., Lang, S., Hay, G.J. (Eds.), Object-based Image Analysis. Springer Berlin Heidelberg, Berlin, Heidelberg, pp. 679-695. doi:10.1007/978-3-540-77058-9_37.
Dice, L.R., 1945. Measures of the amount of ecologic association between species. Ecology, 26(3), pp.297-302.
Feitosa, R.Q., Ferreira, R.S., Almeida, C.M., Camargo, F.F., Costa, G.A.O.P., 2010. Similarity metrics for genetic adaptation of segmentation parameters. In: 3rd International Conference on Geographic Object-Based Image Analysis (GEOBIA 2010). The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Ghent.
Jaccard, P., 1912. The distribution of the flora in the alpine zone.
New phytologist, 11(2), pp.37-50. doi:10.1111/j.1469-8137.1912.tb05611.x
Janssen, L.L.F., Molenaar, M., 1995. Terrain objects, their dynamics and their monitoring by the integration of GIS and remote sensing. IEEE Trans. Geosci. Remote Sens. 33, pp. 749-758. doi:10.1109/36.387590.
Levine, M.D., Nazif, A.M., 1982. An experimental rule based system for testing low level segmentation strategies. In: Preston, K., Uhr, L. (Eds.), Multicomputers and Image Processing: Algorithms and Programs. Academic Press, New York, pp. 149-160.
Lucieer, A., Stein, A., 2002. Existential uncertainty of spatial objects segmented from satellite sensor imagery. Geosci. Remote. Sens. IEEE Trans. 40, pp. 2518-2521. doi:10.1109/TGRS.2002.805072.
Möller, M., Lymburner, L., Volk, M., 2007. The comparison index: a tool for assessing the accuracy of image segmentation. Int. J. Appl. Earth Obs. Geoinf. 9, pp. 311-321. doi:10.1016/j.jag.2006.10.002.
Persello, C., Bruzzone, L., 2010. A novel protocol for accuracy assessment in classification of very high resolution images. IEEE Trans. Geosci. Remote Sens. 48, pp. 1232-1244. doi:10.1109/TGRS.2009.2029570.
Rezatofighi, H., Tsoi, N., Gwak, J., Sadeghian, A., Reid, I., Savarese, S.,
In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 658-666.
Van Coillie, F.M.B., Verbeke, L.P.C., De Wulf, R.R., 2008. Semi-automated forest stand delineation using wavelet based segmentation of very high resolution optical imagery. In: Object-Based Image Analysis: Spatial Concepts for Knowledge-Driven Remote Sensing Applications, pp. 237-256. doi:10.1007/978-3-540-77058-9_13.
Van Rijsbergen, C.J., 1979. Information Retrieval. Butterworth-Heinemann, London.
Weidner, U., 2008. Contribution to the assessment of segmentation quality for remote sensing applications. In: Proceedings of the 21st Congress for the International Society for Photogrammetry and Remote Sensing, 03–11 July, Beijing, China. Vol. XXXVII. Part B7, pp. 479-484.
Yang, J., Li, P., He, Y., 2014. A multi-band approach to unsupervised scale parameter selection for multi-scale image segmentation. ISPRS J. Photogramm. Remote Sens. 94, pp. 13-24. doi:10.1016/j.isprsjprs.2014.04.008.
Yang, J., He, Y., Caspersen, J. P., Jones, T. A., 2017. Delineating Individual Tree Crowns in an Uneven-Aged, Mixed Broadleaf Forest Using Multispectral Watershed Segmentation and Multiscale Fitting. IEEE J. Sel. Top. Appl. Earth Obs. Remote Sens., 10(4), pp. 1390-1401. doi:10.1109/JSTARS.2016.2638822.
Zhan, Q., Molenaar, M., Tempfli, K., Shi, W., 2005. Quality assessment for geo‐spatial objects derived from remotely sensed data. International Journal of Remote Sensing, 26(14), pp.2953-2974. doi:10.1080/01431160500057764
Zhang, X., Feng, X., Xiao, P., He, G., Zhu, L., 2015a. Segmentation quality evaluation using region-based precision and recall measures for remote sensing images. ISPRS J. Photogramm. Remote Sens. 102, pp. 73-84. doi:10.1016/j.isprsjprs.2015.01.009.
Useful links:
Report bugs at https://github.com/michellepicoli/segmetric/issues
These functions manipulate segmetric objects.
sm_area()
: Return a vector of areas, one for each polygon.
sm_centroid()
: Return the centroids of the given polygons.
sm_intersection()
: Return the intersection of the given simple features.
sm_subset_union()
: Return the union of the given simple features.
sm_rbind()
: Return the merge of unique simple features.
sm_summarize_groups()
: Summarizes metric values by a group
(either reference or segment).
sm_options()
: Get/Set segmetric options.
sm_area(s, order = NULL) sm_centroid(s, order = NULL) sm_distance(s1, s2) sm_intersection(s1, s2, touches = TRUE) sm_subset_union(s) sm_rbind(...) sm_apply_group(x, groups, fn, ...) sm_summarize_group(x, groups, fn, ...) sm_norm_left(x, y) sm_norm_right(x, y) sm_options(..., digits = NULL)
sm_area(s, order = NULL) sm_centroid(s, order = NULL) sm_distance(s1, s2) sm_intersection(s1, s2, touches = TRUE) sm_subset_union(s) sm_rbind(...) sm_apply_group(x, groups, fn, ...) sm_summarize_group(x, groups, fn, ...) sm_norm_left(x, y) sm_norm_right(x, y) sm_options(..., digits = NULL)
s , s1 , s2
|
Either a |
order |
A |
touches |
A |
... |
For |
x , y
|
A |
groups |
A group identifier vector used to aggregate a metric for each group. |
fn |
A |
digits |
An |
sm_area()
: Return a numeric
vector with polygons' area.
sm_centroid()
: Return a subset_sf
object with polygons' centroid.
sm_intersection()
: Return a subset_sf
object with intersection
between polygons.
sm_subset_union()
: Return a subset_sf
object with union
between intersecting polygons.
sm_rbind()
: Return a subset_sf
object with unique features.
The sm_compute()
computes a given metric (metric_id
parameter) from
segmentation objects. It compares the reference to the segmentation
polygons using a metric.
A list with all supported metrics can be obtained
by sm_list_metrics()
(see Details for more information).
The sm_metric_subset()
returns the subset used to compute the metrics
in segmetric object.
sm_compute(m, metric_id, ...) sm_metric_subset(m, metric_id = NULL)
sm_compute(m, metric_id, ...) sm_metric_subset(m, metric_id = NULL)
m |
A |
metric_id |
A |
... |
Any additional argument to compute a metric (see Details). |
"OS1
" refers to Oversegmentation. Its values range from 0 (optimal) to 1
(Clinton et al., 2010).
"US1
" refers to Undersegmentation. Its values range from 0 (optimal) to 1
(Clinton et al., 2010).
"OS2
" refers to Oversegmentation. Its values range from 0 (optimal) to 1
(Persello and Bruzzone, 2010).
"US2
" refers to Undersegmentation. Its values range from 0 (optimal) to 1
(Persello and Bruzzone, 2010).
"OS3
" refers to Oversegmentation. Its values range from 0 (optimal) to 1
(Yang et al., 2014).
"US3
" refers to Undersegmentation. Its values range from 0 (optimal) to 1
(Yang et al., 2014).
"AFI
" refers to Area Fit Index. Its optimal value is 0 (Lucieer and Stein,
2002; Clinton et al., 2010).
"QR
" refers to Quality Rate. Its values range from 0 (optimal) to 1
(Weidner, 2008; Clinton et al., 2010).
"D_index
" refers to Index D. Its values range from 0 (optimal) to 1
(Levine and Nazif, 1982; Clinton et al., 2010).
"precision
" refers to Precision. Its values range from 0 to 1 (optimal)
(Van Rijsbergen, 1979; Zhang et al., 2015).
"recall
" refers to Recall. Its values range from 0 to 1 (optimal) (Van
Rijsbergen, 1979; Zhang et al., 2015).
"UMerging
" refers to Undermerging. Its values range from 0 (optimal) to 1
(Levine and Nazif, 1982; Clinton et al., 2010).
"OMerging
" refers to Overmerging. Its optimal value is 0
(Levine and Nazif, 1982; Clinton et al., 2010).
"M
" refers to Match. Its values range from 0 to 1 (optimal) (Janssen and
Molenaar, 1995; Feitosa et al., 2010).
"E
" refers to Evaluation Measure. Its values range from 0 (optimal) to 100
(Carleer et al., 2005).
"RAsub
" refers to Relative Area. Its values range from 0 to 1 (optimal)
(Müller et al., 2007; Clinton et al., 2010).
"RAsuper
" refers to Relative area. Its values range from 0 to 1 (optimal)
(Müller et al., 2007; Clinton et al., 2010).
"PI
" refers to Purity Index. Its values range from 0 to 1 (optimal) (van
Coillie et al., 2008).
"Fitness
" refers to Fitness Function. Its optimal value is 0 (Costa et al.,
2008).
"ED3
" refers to Euclidean Distance. Its values range from 0 (optimal) to 1
(Yang et al., 2014).
"F_measure
" refers to F-measure metric. Its values range from 0 to 1
(optimal) (Van Rijsbergen, 1979; Zhang et al., 2015). It takes the optional
weight argument alpha
, ranging from 0.0
to 1.0
(the default is 0.5
).
"IoU
" refers to Intersection over Union metric. Its values range
from 0 to 1 (optimal) (Jaccard, 1912; Rezatofighi et al., 2019).
"SimSize
" refers to the similarity size metric. Its values range from
0 to 1 (optimal) (Zhan et al., 2005).
"qLoc
"refers to quality of object’s location metric. Its optimal value
is 0 (Zhan et al., 2005).
"RPsub
" refers to Relative Position (sub) metric. Optimal value is 0
(Möller et al., 2007, Clinton et al., 2010).
"RPsuper
" refers to Relative Position (super) metric. Its values range
from 0 (optimal) to 1 (Möller et al., 2007, Clinton et al., 2010).
"OI2
refers to Overlap Index metric. Its values range from 0 to 1
(optimal) (Yang et al., 2017).
Return a numeric
vector with computed metric.
A complete list of cited references is available in ?segmetric
.
sm_list_metrics()
# load sample 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) # compute AFI metric and summarize it sm_compute(m, "AFI") %>% summary() # compute three metrics and summarize them sm_compute(m, c("AFI", "OS1", "US2")) %>% summary() # compute OS1, F_measure, and US2 metrics using pipe m <- sm_compute(m, "OS1") %>% sm_compute("F_measure") %>% sm_compute("US2") # summarize them summary(m)
# load sample 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) # compute AFI metric and summarize it sm_compute(m, "AFI") %>% summary() # compute three metrics and summarize them sm_compute(m, c("AFI", "OS1", "US2")) %>% summary() # compute OS1, F_measure, and US2 metrics using pipe m <- sm_compute(m, "OS1") %>% sm_compute("F_measure") %>% sm_compute("US2") # summarize them summary(m)
Plot a segmetric map according to the parameter type
:
"base"
: simple plot of the reference or segmentation polygons;
"subset"
: plot polygons from a subset over the base plot;
"choropleth"
: plot a choropleth map from polygons of a subset using
metric values.
## S3 method for class 'segmetric' plot( x, type = "base", ..., title = NULL, layers = c("ref_sf", "seg_sf"), background = "#FFFFFF", ref_color = "#FF00009F", ref_fill = "#FFFFFF00", ref_label = "reference", ref_size = 2, ref_symbol = 2, seg_color = "#0000009F", seg_fill = "#FFFFFF00", seg_label = "segment", seg_size = 1, seg_symbol = 3, selected_fill = "#9A9AFF50", plot_centroids = TRUE, centroids_color = "#000000FF", centroids_label = "centroid", subset_id = NULL, subset_color = "#FFFFFF00", subset_fill = "#F0E4167F", metric_id = NULL, break_style = "jenks", choropleth_palette = "YlGnBu", choropleth_palette_reverse = FALSE, choropleth_size = 0.1, plot_extent = NULL, plot_legend = TRUE, plot_axes = TRUE )
## S3 method for class 'segmetric' plot( x, type = "base", ..., title = NULL, layers = c("ref_sf", "seg_sf"), background = "#FFFFFF", ref_color = "#FF00009F", ref_fill = "#FFFFFF00", ref_label = "reference", ref_size = 2, ref_symbol = 2, seg_color = "#0000009F", seg_fill = "#FFFFFF00", seg_label = "segment", seg_size = 1, seg_symbol = 3, selected_fill = "#9A9AFF50", plot_centroids = TRUE, centroids_color = "#000000FF", centroids_label = "centroid", subset_id = NULL, subset_color = "#FFFFFF00", subset_fill = "#F0E4167F", metric_id = NULL, break_style = "jenks", choropleth_palette = "YlGnBu", choropleth_palette_reverse = FALSE, choropleth_size = 0.1, plot_extent = NULL, plot_legend = TRUE, plot_axes = TRUE )
x |
A |
type |
A |
... |
Ignored. |
title |
A |
layers |
A |
background |
A |
ref_color , seg_color , ref_fill , seg_fill
|
A |
ref_label , seg_label , centroids_label
|
A |
ref_size , seg_size
|
A |
ref_symbol , seg_symbol
|
An |
selected_fill |
A |
plot_centroids |
A |
centroids_color |
A |
subset_id |
A |
subset_color , subset_fill
|
A |
metric_id |
A |
break_style |
A |
choropleth_palette |
A |
choropleth_palette_reverse |
A |
choropleth_size |
A |
plot_extent |
A |
plot_legend |
A |
plot_axes |
A |
ref_sf
: a dataset containing field boundaries from Luiz Eduardo Magalhaes
municipality, Brazil.
The data covers the following extent: xmin: -46.37683 ymin: -12.34579 xmax: -46.15776 ymax: -12.13663 CRS: EPSG:4326
sample_ref_sf
: a subset of ref_sf
dataset.
ref_sf sample_ref_sf
ref_sf sample_ref_sf
These datasets are objects of class sf
(inherited from tbl_df
,
tbl
, data.frame
) with 2 variables:
id
: identification
geometry
: polygons
ref_sf
: a dataset with 195 features.
sample_ref_sf
: a dataset with 5 features.
Oldoni et al. (2020) doi:10.1016/j.dib.2020.106553.
Oldoni, L.V., Sanches, I.D.A., Picoli, M.C.A., Covre, R.M. and Fronza, J.G., 2020. LEM+ dataset: For agricultural remote sensing applications. Data in Brief, 33, p.106553.
data("ref_sf", package = "segmetric") data("sample_ref_sf", package = "segmetric")
data("ref_sf", package = "segmetric") data("sample_ref_sf", package = "segmetric")
seg200_sf
,seg500_sf
,seg800_sf
,seg1000_sf
: a dataset containing
segments generated from PlanetScope image, level 3B, acquired on
Feb 18, 2020, with 3.7-meter resolution (Planet Team, 2017), using the
multiresolution segmentation method (Baatz and Schape, 2000).
The data covers the approximately the same area of LEM+ dataset (see ref_sf).
The data was post-processed using the spectral difference algorithm on band 3.
The polygons were simplified using the Douglas-Peucker algorithm in QGIS.
Self-intersections were removed using SAGA's Polygon Self-Intersection.
Segmentation parameters:
scale parameter
: 200 (seg200_sf
), 500 (seg500_sf
),
800 (seg800_sf
), and 1000 (seg1000_sf
)
shape
: 0.9
compactness
: 0.1
Spectral difference parameters:
spectral difference
: 20
Simplification parameter:
distance
: 10-meters
Only those polygons intersecting reference data with an area-perimeter ratio above 25 were selected.
sample_seg_sf
: a subset of seg_sf
dataset.
seg200_sf seg500_sf seg800_sf seg1000_sf sample_seg_sf
seg200_sf seg500_sf seg800_sf seg1000_sf sample_seg_sf
These datasets are objects of class sf
(inherited from tbl_df
,
tbl
, data.frame
) with 2 variables:
id
: identification
geometry
: polygons
seg200_sf
: a dataset with 547 features.
seg500_sf
: a dataset with 215 features.
seg800_sf
: a dataset with 169 features.
seg1000_sf
: a dataset with 158 features.
An object of class sf
(inherits from tbl_df
, tbl
, data.frame
) with 215 rows and 2 columns.
An object of class sf
(inherits from tbl_df
, tbl
, data.frame
) with 169 rows and 2 columns.
An object of class sf
(inherits from tbl_df
, tbl
, data.frame
) with 158 rows and 2 columns.
sample_seg_sf
: a dataset with 6 features extracted from
seg500_sf
dataset.
Planet Team, 2017. Planet Application Program Interface: In Space for Life on Earth. San Francisco, CA. https://www.planet.com
Baatz, M., Schape, A., 2000. Multiresolution segmentation - an optimization approach for high quality multi-scale image segmentation. In: Strobl, J., Blaschke, T., Griesebner, G. (Eds.), Angewandte Geographische Informations-Verarbeitung XII. Wichmann Verlag, Karlsruhe, Germany, pp. 12-23. <>
data("seg200_sf", package = "segmetric") data("seg500_sf", package = "segmetric") data("seg800_sf", package = "segmetric") data("seg1000_sf", package = "segmetric") data("sample_seg_sf", package = "segmetric")
data("seg200_sf", package = "segmetric") data("seg500_sf", package = "segmetric") data("seg800_sf", package = "segmetric") data("seg1000_sf", package = "segmetric") data("sample_seg_sf", package = "segmetric")
These functions compute subsets required to calculate segmentation metrics as described in Clinton et al. (2010) and Costa et al. (2017).
sm_ref()
returns the set of polygons of reference,
represented by
sm_seg()
returns the set of segmentation polygons,
represented by
sm_ytilde()
returns , a subset of
,
where
sm_xtilde()
returns , a subset of
, where
sm_yprime()
returns , a subset of
, where
sm_xprime()
returns , a subset of
, where
sm_ya()
returns , a subset of
,
where
sm_yb()
returns , a subset of
,
where
sm_yc()
returns , a subset of
,
where
sm_yd()
returns , a subset of
,
where
sm_ystar()
returns , where
sm_ycd()
returns , where
sm_ye()
returns , a subset of
,
where
sm_yf()
returns , a subset of
,
where
sm_yg()
returns , a subset of
,
where
sm_ytilde(m) sm_xtilde(m) sm_yprime(m) sm_xprime(m) sm_ya(m) sm_yb(m) sm_yc(m) sm_yd(m) sm_ystar(m) sm_ycd(m) sm_ye(m) sm_yf(m) sm_yg(m)
sm_ytilde(m) sm_xtilde(m) sm_yprime(m) sm_xprime(m) sm_ya(m) sm_yb(m) sm_yc(m) sm_yd(m) sm_ystar(m) sm_ycd(m) sm_ye(m) sm_yf(m) sm_yg(m)
m |
A |
sm_ref()
: Return an object of class ref_sf
(inherited from sf
)
containing identification (ref_id
) and geometry (geometry
) columns.
sm_seg()
: Return an object of class seg_sf
(inherited from sf
)
containing identification (seg_id
) and geometry (geometry
) columns.
sm_ytilde()
, sm_xtilde()
, sm_yprime()
, sm_xprime()
, sm_ya()
,
sm_yb()
, sm_yc()
, sm_yd()
, sm_ystar()
, sm_ycd()
, sm_ye()
,
sm_yf()
, and sm_yg()
: Return an object of class subset_sf
(inherited from sf
) containing identification (ref_id
and seg_id
),
and geometry (geometry
) columns.
Clinton, N., Holt, A., Scarborough, J., Yan, L., & Gong, P. (2010). Accuracy Assessment Measures for Object-based Image Segmentation Goodness. Photogrammetric Engineering & Remote Sensing, 76(3), 289–299. doi:10.14358/PERS.76.3.289.
Costa, H., Foody, G. M., & Boyd, D. S. (2018). Supervised methods of image segmentation accuracy assessment in land cover mapping. Remote Sensing of Environment, 205(December 2017), 338–351. doi:10.1016/j.rse.2017.11.024.
These functions are intended to be used in new metric extensions.
They handle subset_sf
data (inherited from sf
class) stored in
segmetric
objects.
sm_list()
lists subsets already computed and stored in a segmetric
object.
sm_exists()
verifies if a subset_id
exists in a segmetric
object.
sm_subset()
evaluates and stores a subset_sf
object.
sm_indirect()
finds the subset_id
of a given subset_sf
object stored
in a segmetric
object.
sm_segmetric()
returns the segmetric
object that stores a given
subset
object (either a ref_sf
, a seg_sf
, or a subset_sf
).
sm_get()
retrieves a subset_sf
object stored in a segmetric
object.
sm_inset()
operator equivalent to inner join but returns only objects
from s1
, or its corresponding row in s2
if parameter return_index
is TRUE
.
sm_group_by()
: Apply a function to groups of subset_sf
.
sm_list(m) sm_exists(m, subset_id) sm_subset(m, subset_id, expr = NULL) sm_indirect(s) sm_segmetric(s) sm_get(m, subset_id) sm_ref(m) sm_seg(m) sm_inset(s1, s2, return_index = FALSE) ## S3 method for class 'ref_sf' sm_inset(s1, s2, return_index = FALSE) ## S3 method for class 'seg_sf' sm_inset(s1, s2, return_index = FALSE) ## S3 method for class 'subset_sf' sm_inset(s1, s2, return_index = FALSE) sm_group_by(s, by, fn, ...)
sm_list(m) sm_exists(m, subset_id) sm_subset(m, subset_id, expr = NULL) sm_indirect(s) sm_segmetric(s) sm_get(m, subset_id) sm_ref(m) sm_seg(m) sm_inset(s1, s2, return_index = FALSE) ## S3 method for class 'ref_sf' sm_inset(s1, s2, return_index = FALSE) ## S3 method for class 'seg_sf' sm_inset(s1, s2, return_index = FALSE) ## S3 method for class 'subset_sf' sm_inset(s1, s2, return_index = FALSE) sm_group_by(s, by, fn, ...)
m |
A |
subset_id |
A |
expr |
A valid piece of code in R inside curly braces. This code is evaluated to generate a subset. |
s , s1 , s2
|
Either a |
return_index |
A |
by |
A |
fn |
A |
... |
For |
sm_list()
: Return a character
vector with all names of subsets stored
in the segmetric
object.
sm_exists()
: Return a logical
value indicating if a given subset name is
stored in the segmetric
object.
sm_subset()
: Return a subset_sf
object.
sm_indirect()
: Return the subset name of a given subset_sf
object
stored in a segmetric
object.
sm_segmetric()
: Return a segmetric
object that stores a given
subset_sf
object.
sm_get()
: Return a subset_sf
object stored in a segmetric
object.
sm_inset()
: Return either a subset_sf
object or an integer
vector
with the index of corresponding rows of s2
object.
sm_group_by()
: Return a subset_sf
object.
# load sample 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) # lists only 'ref_sf' and 'seg_sf' sm_list(m) # computes 'Y_tilde' subset and stores it as 'test_subset' subset id # sm_ytilde(m) also stores a subset under 'Y_tilde' id s <- sm_subset(m, "test_subset", sm_ytilde(m)) # lists 'ref_sf', 'seg_sf', 'test_subset', and 'Y_tilde' sm_list(m) # which segmetric object stores `s` subset? m2 <- sm_segmetric(s) # m is identical to m2 identical(m, m2) # which name `s` subset is stored in `m` segmetric object? sm_indirect(s) # retrieve 'test_subset' data from `m` object s2 <- sm_get(m, 'test_subset') # s is identical to s2 identical(s, s2)
# load sample 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) # lists only 'ref_sf' and 'seg_sf' sm_list(m) # computes 'Y_tilde' subset and stores it as 'test_subset' subset id # sm_ytilde(m) also stores a subset under 'Y_tilde' id s <- sm_subset(m, "test_subset", sm_ytilde(m)) # lists 'ref_sf', 'seg_sf', 'test_subset', and 'Y_tilde' sm_list(m) # which segmetric object stores `s` subset? m2 <- sm_segmetric(s) # m is identical to m2 identical(m, m2) # which name `s` subset is stored in `m` segmetric object? sm_indirect(s) # retrieve 'test_subset' data from `m` object s2 <- sm_get(m, 'test_subset') # s is identical to s2 identical(s, s2)