Skip to contents

The import_env function imports environmental base data for macroinvertebrate sampling sites from the Environment Agency's Ecology and Fish Data Explorer. The data can either be downloaded from https://environment.data.gov.uk/ecology-fish/downloads/INV_OPEN_DATA.zip or read in from a local csv or rds file. The data can be optionally filtered by site ID.

Usage

import_env(env_dir = NULL, sites = NULL, save = FALSE, save_dwnld = FALSE, save_dir = getwd())

Arguments

env_dir

Path to local csv or rds file containing environmental data. If NULL (default), then data is downloaded from data.gov.uk.

sites

Vector of site ids to filter on.

save

Specifies if imported environmental data should be saved as rds file (for future use); Default = FALSE.

save_dwnld

Specifies if downloaded biology data should be saved.

save_dir

Path to folder where imported environmental data is to be saved; Default = Current working directory.

Value

Tibble containing environmental data

Details

If saving a copy of the downloaded data, the name of the rds file is hard-wired to: INV_OPEN_DATA_SITES_ALL.rds. If saving after filtering on site, the name of the rds file is hard-wired to: INV_OPEN_DATA_SITE_F.rds.

Downloaded raw data files (in .csv and .zip format) will be automatically removed from the working directory following completed execution of the function.

The function will modify the output from EDE, renaming SITE_ID to biol_site_id (hetoolkit's standardised column header for biology sites).

Examples

# Download data for all sites and save as .rds file for future use:
  # import_env(save_dwnld = TRUE, save_dir = "mydata")

# Read in local .rds file and filter on selected sites:
  # import_env(env_dir = "mydata/INV_OPEN_DATA_SITES_ALL.rds",
  #                sites = c("34310", "34343"))

# Read in local .csv file and filter on selected sites:
  # import_env(env_dir = "mydata/INV_OPEN_DATA_SITES_ALL.csv",
  #               sites = c("34310", "34343"))