Map taxonomic observations from a data frame. Input a dataframe with SampID, TaxaID, TaxaCount, Latitude, and Longitude. Other arguments are format (jpg vs. pdf), file name prefix, and output directory. Files are saved with the prefix "map.taxa." by default.

MapTaxaObs(
  df_obs,
  SampID,
  TaxaID,
  TaxaCount,
  Lat,
  Long,
  output_dir = NULL,
  output_prefix = "maps.taxa",
  output_type = "pdf",
  database,
  regions,
  map_grp = NULL,
  leg_loc = "right",
  ...
)

Arguments

df_obs

Observation data frame

SampID

df_obs column name, Unique Sample identifier

TaxaID

df_obs column name, Unique Taxa identifier

TaxaCount

df_obs column name, Number of individuals for TaxonID and SampID

Lat

df_obs column name, Latitude

Long

df_obs column name, Longitude

output_dir

Directory to save output. Default is working directory.

output_prefix

Prefix to TaxaID for each file. Default = "map.taxa."

output_type

File format for output; jpg or pdf.

database

maps::map function database; world, usa, state, county

regions

maps::map function regions. Names pertinent to map_db.

map_grp

Map grouping variable from df_obs. Will generate legend and color code the points on the map. Default = NULL

leg_loc

Legend location text. Default = "right" Other values may not work properly.

...

Optional arguments to be passed to methods.

Value

Taxa maps to user defined directory as jpg or pdf.

Details

The user will pass arguments for maps::map function that is used for the map. For example, 'database' and 'regions'. Without these arguments no map will be created.

The map will have all points and colored points for each taxon. In addition the map will include the number of samples by taxon.

The example data is fish but can be used for benthic macroinvertebrates as well.

If use grouping variable colors are from grDevices::rainbow()

Jpg file names replace all non-alphanumeric characters with "_".

The R package maps is required for this function.

Examples

df_obs <- data_Taxa_MA
SampID <- "estuary"
TaxaID <- "TaxaName"
TaxaCount <- "Count"
Lat <- "Latitude"
Long <- "Longitude"
output_dir <- tempdir()
output_prefix <- "maps.taxa."
output_type <- "pdf"

myDB <- "state"
myRegion <- "massachusetts"
myXlim     <- c(-(73+(30/60)), -(69+(56/60)))
myYlim     <- c((41+(14/60)),(42+(53/60)))

# Run function with extra arguments for map
if (FALSE) {
MapTaxaObs(df_obs
           , SampID
           , TaxaID
           , TaxaCount
           , Lat
           , Long
           , database="state"
           , regions="massachusetts"
           , xlim = myXlim
           , ylim = myYlim
           , map_grp = "estuary"
           , leg_loc = "bottomleft")
}