Given two previously related levels of a dimension, it obtains the instances of the lower level that have not been related to the upper level.
Usage
get_unrelated_instances(gd, lower_level_name, upper_level_name)
# S3 method for geodimension
get_unrelated_instances(gd, lower_level_name = NULL, upper_level_name = NULL)
Arguments
- gd
A
geodimension
object.- lower_level_name
A string, name of the lower level.
- upper_level_name
A string, name of the upper lever.
See also
Other relationship between geolevels:
complete_relation_by_geography()
,
relate_levels()
,
select_levels()
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 <-
geodimension(name = "gd_us",
level = place) |>
add_level(level = county)
gd <- gd |>
relate_levels(
lower_level_name = "place",
upper_level_name = "county",
by_geography = TRUE
)
ui <- gd |>
get_unrelated_instances(
lower_level_name = "place",
upper_level_name = "county"
)