Skip to contents

Transform the CRS of all the layers included in the dimension to the one indicated.

Usage

transform_crs(gd, crs = NULL)

# S3 method for geodimension
transform_crs(gd, crs = NULL)

Arguments

gd

A geodimension object.

crs

A coordinate reference system: integer with the EPSG code, or character with proj4string.

Value

A geodimension.

See also

geolevel, relate_levels, get_level_layer

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

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) |>
  transform_crs(crs = 3857)