Skip to contents

From the coordinates defined in fields such as latitude and longitude, it returns a layer of points.

Usage

coordinates_to_geometry(table, lon_lat = c("intptlon", "intptlat"), crs = 4326)

Arguments

table

A tibble object.

lon_lat

A vector, name of longitude and latitude attributes.

crs

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

Value

A sf object.

Details

If we start from a geographic layer, it initially transforms it into a table.

The CRS of the new layer is indicated. By default, it considers 4326 (WGS84).

See also

Examples


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()

us_county_point <-
  coordinates_to_geometry(layer_us_county,
                          lon_lat = c("intptlon", "intptlat"))