Get the table of group attributes

getGroups(x)

# S4 method for ANY
getGroups(x)

# S4 method for geom
getGroups(x)

# S4 method for Raster
getGroups(x)

# S4 method for SpatRaster
getGroups(x)

Arguments

x

the object from which to derive the attribute table.

Value

A tibble (or a list of tibbles per layer) of the group attributes of x.

Details

This table contains at least the column 'gid'.

When this function is called on "ANY" object, it is first tested whether that object has features (getFeatures), from which the groups can be reconstructed. If this is not the case, NULL is returned.

See also

Examples


getGroups(gtGeoms$polygon)
#> # A tibble: 2 × 1
#>     gid
#>   <int>
#> 1     1
#> 2     2

gc_sp(gtGeoms$line) %>%
  getGroups()
#> # A tibble: 2 × 1
#>     gid
#>   <dbl>
#> 1     1
#> 2     2

gc_sf(gtGeoms$line) %>%
  getGroups()
#> # A tibble: 2 × 1
#>     gid
#>   <dbl>
#> 1     1
#> 2     2

# for gridded objects, groups are unique pixel values, and their
# attributes are in the raster attribute table (RAT)
gc_raster(gtGeoms$grid$categorical) %>%
  getGroups()
#> # A tibble: 9 × 2
#>     gid cover            
#>   <int> <fct>            
#> 1     1 lake             
#> 2    11 sealed           
#> 3    21 wetland          
#> 4    24 arable           
#> 5    27 pasture          
#> 6    31 clearcut         
#> 7    41 deciduous forest 
#> 8    44 coniferous forest
#> 9    47 mixed forest     

gc_terra(gtGeoms$grid$categorical) %>%
  getGroups()
#> # A tibble: 9 × 2
#>     gid cover            
#>   <dbl> <chr>            
#> 1     1 lake             
#> 2    11 sealed           
#> 3    21 wetland          
#> 4    24 arable           
#> 5    27 pasture          
#> 6    31 clearcut         
#> 7    41 deciduous forest 
#> 8    44 coniferous forest
#> 9    47 mixed forest