This function allows to subset any geometric object for which all required getters are available.

gt_filter(obj, ..., update = TRUE)

Arguments

obj

[geometric object(1)]
the object to derive a subset from.

...

subset based on logical predicates defined in terms of the columns in x (of both, points, features and groups). Multiple conditions are combined with &. Only rows where the condition evaluates to TRUE are kept.

update

[logical(1)]
whether or not to update the window slot after deriving the subset.

Value

geom of the subset of obj.

See also

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

Examples

gt_filter(gtGeoms$point, y < -10)
#> geom        point
#>             2 groups | 4 features | 4 points
#> crs         cartesian
#> attributes  --
#> tiny map           -20 
#>                    ◌ ◌ ◌ ◌       
#>                    ◌ ◌ ◌ ◌       
#>                    ◌ ◌ ◌ ◌       
#>             -34.64 ◌ ◎ ◎ ◌ 34.64 
#>                    -40 

newObj <- setFeatures(x = gtGeoms$point,
                      table = data.frame(fid = c(1:9),
                                         attrib = c(letters[1:9])))

gt_filter(obj = newObj, attrib %in% c("a", "c", "e"))
#> geom        point
#>             1 group | 3 features | 3 points
#> crs         cartesian
#> attributes  (features) attrib
#> tiny map           20 
#>                    ◌ ◌ ◌ ◌       
#>                    ◌ ◌ ◌ ◌       
#>                    ◌ ◌ ◌ ◌       
#>             -34.64 ◌ ◉ ◉ ◌ 34.64 
#>                    -40