This function adds location data to the rows of a SAFE data worksheet, converting it into a sf spatial features object. Rows are matched to values in a location_field: if there is only one location field, it will be used automatically; otherwise, the specific field must be provided.

add_locations(
  obj,
  location_field = NULL,
  location_table = NULL,
  gazetteer_info = FALSE
)

Arguments

obj

An existing object of class safedata

location_field

The name of a location field in a safedata object.

location_table

An existing location table for a dataset, as generated by get_locations.

gazetteer_info

Should all the gazetteer fields be included in the returned sf object. See load_gazetteer for details.

Value

A modified safedata object including geometry data.

Examples

   set_example_safe_dir()
#> Loading and caching index
#> Validating directory
   beetle_abund <- load_safe_data(1400562, "Ant-Psel")
   beetle_abund <- add_locations(beetle_abund)
   unset_example_safe_dir()