This function reads site location data, either provided as a data frame or loaded from the included package dataset, cleans it, and converts it into a simple features (SF) object for spatial analysis.
Arguments
- x
A data frame containing site location data with columns for station IDs, elevation, site names, and coordinates. If `NULL`, the function will load the `SiteLocations` dataset from the package.
Details
The `SiteData` function performs the following steps:
If no input data is provided (`x = NULL`), it loads the `SiteLocations` dataset from the `TNCDangermond` package.
Converts `station_id_dendra`, `elev`, and `SiteName` columns to character type.
Cleans up the `station_id_dendra` and `elev` columns, handling missing values and inconsistencies.
Transforms `SiteName` to replace spaces with underscores.
Filters rows where `SiteName` starts with "Dangermond" and excludes those containing "Weather".
Converts the cleaned data to an SF object with coordinates defined by `lon` and `lat`, and sets the coordinate reference system (CRS) to EPSG:4269.