complete_relation_by_geography {geodimension} | R Documentation |
Complete relation by geography
Description
Two levels can be related by attributes or by geography (if the upper level has polygon-type geometry). Once related, if there are unrelated instances, we can try to relate those instances using this function, which considers alternative geographic relationships.
Usage
complete_relation_by_geography(
gd,
lower_level_name = NULL,
upper_level_name = NULL
)
## S3 method for class 'geodimension'
complete_relation_by_geography(
gd,
lower_level_name = NULL,
upper_level_name = NULL
)
Arguments
gd |
A |
lower_level_name |
A string, name of the lower level. |
upper_level_name |
A string, name of the upper lever. |
Details
It does not necessarily succeed trying to relate instances.
Value
A geodimension
object.
See Also
Other relationship between geolevels:
get_unrelated_instances()
,
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",
lower_level_attributes = "county_geoid",
upper_level_name = "county"
) |>
complete_relation_by_geography(
lower_level_name = "place",
upper_level_name = "county"
)
[Package geodimension version 2.0.0 Index]