Skip to contents

Convert the coordinate reference system, convert invalid geometry to valid geometry with sf::st_make_valid(), and, optionally, erase water, and clean names with janitor::clean_names().

Usage

format_md_sf(
  data,
  crs = getOption("mapmaryland.crs", default = 3857),
  erase_water = FALSE,
  erase_data = NULL,
  clean_names = TRUE,
  dTolerance = NULL,
  smooth = FALSE,
  sf_col = "geometry",
  ...
)

Arguments

data

A sf object or for (format_md_crash_data() only) a data.frame object.

crs

coordinate reference system. Defaults to getOption("mapmaryland.crs", default = 3857). This option can be set with set_mapmaryland_options().

erase_water

If TRUE, erase any geometry intersecting with md_water; Default: FALSE. If TRUE, and erase_data is not NULL, md_water is combined and unioned with erase_data.

erase_data

A sf, sfc, or bbox object with geometry that should be erased from the data, Default: NULL

clean_names

If TRUE, set .name_repair to janitor::make_clean_names(); defaults to TRUE.

dTolerance

numeric; tolerance parameter, specified for all or for each feature geometry. If you run st_simplify, the input data is specified with long-lat coordinates and sf_use_s2() returns TRUE, then the value of dTolerance must be specified in meters.

smooth

If TRUE, smooth data with smoothr::smooth using default method and parameters, Default: FALSE.

sf_col

Name to use for output sf column, Default: 'geometry'.

...

Additional parameters passed to format_data

Value

A modified version of the input simple feature data.