Skip to contents

Defines a geographic attributes in two possible ways: Associates the instances of attributes of the geographic dimension with the instances of a geographic layer or defines it from the geometry of another previously defined geographic attribute. Multiple attributes can be specified in the attribute parameter.

Usage

define_geoattribute(
  gms,
  dimension = NULL,
  attribute = NULL,
  additional_attributes = NULL,
  from_layer = NULL,
  by = NULL,
  from_attribute = NULL
)

# S3 method for geomultistar
define_geoattribute(
  gms,
  dimension = NULL,
  attribute = NULL,
  additional_attributes = NULL,
  from_layer = NULL,
  by = NULL,
  from_attribute = NULL
)

Arguments

gms

A geomultistar object.

dimension

A string, dimension name.

attribute

A vector, attribute names.

additional_attributes

A vector, attribute names.

from_layer

A sf object.

by

a vector of correspondence of attributes of the dimension with the sf layer structure.

from_attribute

A string, attribute name.

Value

A geomultistar object.

Details

If defined from a layer (from_layer parameter), additionally the attributes used for the join between the tables (dimension and layer tables) must be indicated (by parameter).

If defined from another attribute, it should have a finer granularity, to obtain the result by grouping its instances.

If no value is indicated in the attribute parameter, it is defined for all those attributes of the dimension that do not have any previous definition, they are obtained from the attribute indicated in the from_attribute parameter.

See also

Other geo functions: geomultistar(), get_empty_geoinstances(), run_geoquery()

Examples


gms <- geomultistar(ms = ms_mrs, geodimension = "where") |>
  define_geoattribute(
    attribute = "city",
    from_layer = usa_cities,
    by = c("city" = "city", "state" = "state")
  )

gms <- gms |>
  define_geoattribute(attribute = c("region", "all_where"),
                      from_attribute = "city")

gms <- gms |>
  define_geoattribute(from_attribute = "city")

gms <- gms |>
  define_geoattribute(attribute = "all_where",
                      from_layer = usa_nation)