get_unrelated_instances | R Documentation |
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.
get_unrelated_instances(gd, lower_level_name, upper_level_name)
## S3 method for class 'geodimension'
get_unrelated_instances(gd, lower_level_name = NULL, upper_level_name = NULL)
gd |
A |
lower_level_name |
A string, name of the lower level. |
upper_level_name |
A string, name of the upper lever. |
A tibble
, unrelated lower level instances.
geodimension
, geolevel
Other relationship between geolevels:
complete_relation_by_geography()
,
relate_levels()
,
select_levels()
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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.