Skip to contents

Once a level is part of the dimension, it can then be related to other levels of the dimension.

Usage

add_level(gd, level)

# S3 method for geodimension
add_level(gd, level = NULL)

Arguments

gd

A geodimension object.

level

A geolevel, level to add to the dimension.

Value

A geodimension.

See also

geolevel, relate_levels, get_level_layer

Other geodimension definition functions: geodimension(), set_level_data(), transform_crs()

Examples


layer_us_place <- gd_us |>
  get_level_layer("place")

layer_us_county <-
  dplyr::inner_join(
    get_level_data_geo(gd_us, "county"),
    get_level_layer(gd_us, "county"),
    by = c("geoid", "statefp", "name", "type")
  ) |>
  sf::st_as_sf()

place <-
  geolevel(name = "place",
           layer = layer_us_place,
           attributes = c("statefp", "county_geoid", "name", "type"),
           key = "geoid")

county <-
  geolevel(
    name = "county",
    layer = layer_us_county,
    attributes = c("statefp", "name", "type"),
    key = "geoid"
  ) |>
  add_geometry(coordinates_to_geometry(layer_us_county,
                                       lon_lat = c("intptlon", "intptlat")))

gd_us <-
  geodimension(name = "gd_us",
               level = place) |>
  add_level(level = county)