Transform a spatial object to class geom

gc_geom(input, ...)

# S4 method for Spatial
gc_geom(input = NULL, ...)

# S4 method for sf
gc_geom(input = NULL, group = FALSE, ...)

# S4 method for Raster
gc_geom(input = NULL, stack = FALSE, group = FALSE, as_hex = FALSE, ...)

Arguments

input

the object to transform to class geom.

...

additional arguments.

group

[logical(1)]
should the values of a Raster* or the attributes of MULTI* features be grouped, i.e., should the unique values be assigned into the groups table (TRUE)? The default behaviour for Raster* would be not to assign values into the group attribute table if no RAT is available and for MULTI* features it would be to keep the attributes as duplicated per-feature attributes (FALSE)?

stack

[logical(1)]
should the layers of gridded objects be stacked, i.e., should several layers be stored as columns in the attribute table of features of one geom (TRUE, default), or should they be stored in (a list of) several geoms separately (FALSE)?

as_hex

[logical(1)]
should the bands 'red', 'green' and 'blue' of a gridded object be transformed to hexadecimal values (TRUE), or should they be retained as columns in a stacked grid geom (FALSE, default)?.

Value

an object of class geom

Details

When transforming a simple feature to a geom, all MULTI* features are organised on a per feature basis, where the attribute table of features in the geom contains those variables that are valid for each feature, while the attribute table of groups contains those variables, that are unique only at the level of groups of features (i.e., at the level of MULTI* simple features). Those variables that are valid at the level of groups would be duplicated in the attribute table of features. When a MULTI* feature is transformed to a geom, the default behaviour is to copy the simple feature as closely as possible. However, to reduce the object size (and improve its' organisation), it is possible to assign the attributes of groups into the attribute table of groups of the geom by setting group = TRUE.

When transforming a Raster* (or possibly other gridded classes) with several layers to a geom, the layers are by default organised into a list with a layer per list item. However, when several layers contain fundamentally the same data (i.e., values that are associated to the same groups), layers could be stacked stack = TRUE, because they share the same group attribute table.

See also

Other spatial classes: gc_raster(), gc_sf(), gc_sp(), gc_terra()

Examples

gc_sf(input = gtGeoms$polygon) %>%
  gc_geom()
#> geom        polygon
#>             2 groups | 2 features | 11 points
#> crs         cartesian
#> attributes  --
#> tiny map           40 
#>                    ◌ ○ ○ ◌       
#>                    ◌ ○ ○ ◌       
#>                    ◌ ○ ○ ◌       
#>             -34.64 ◌ ◎ ◎ ◌ 34.64 
#>                    -40 

gc_raster(input = gtGeoms$grid$categorical) %>%
  gc_geom()
#> geom        grid
#>             1 layer | 3360 cells
#> crs         cartesian
#> attributes  cover
#> resolution  1 1 (x, y)
#> extent      0 60 0 56 (xmin, xmax, ymin, ymax)