Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gt_pull

Extract a single column from a geometric object


Description

This function allows to extract a specific column from any geometric object for which all required getters are available and thus reflects the base function $.

Usage

gt_pull(obj, var, ungroup = FALSE)

Arguments

obj

[geometric object(1)]
the object to pull a column from.

var

[character(1)]
name of the variable to pull.

ungroup

[logical(1)]
inversely to the argument group in gc_geom, this argument provides the attribute to pull per each individual feature, producing duplicates in case there is more than one feature per group.

Details

This function searches for var by first looking in the groups, then the features and finally the points of obj. This results always in an output that is limited to the unique cases of var. In case you want the explicit values of, for instance, fid in obj@points, you have to extract points and then use pull on the result.

Value

vector of the column specified in var.

See Also

Other geometry tools: gt_filter(), gt_locate(), gt_reflect(), gt_rotate(), gt_scale(), gt_skew(), gt_stretch(), gt_translate()

Examples

# pull values from a geom (there are two features, thus two values) ...
gt_pull(gtGeoms$point, "fid")

# pull from a Raster* with RAT
gt_pull(gtGeoms$grid$categorical, "cover")

# pull from an sf-object
gt_pull(gtSF$point, "a")

geometr

Generate and Modify Interoperable Geometric Shapes

v0.2.10
GPL-3
Authors
Steffen Ehrmann [aut, cre] (<https://orcid.org/0000-0002-2958-0796>), Dan Sunday [cph] (fast point-in-polygon algorithm.)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.