Map taxonomic observations in Maryland. Inputs are 3 GIS shapefiles (State, County, and Hydrology) for Maryland, Observations (taxa names and Lat/Longs), and #' a crosswalk table of taxa names and map names. Input files are assumed to be Excel with the data on the first worksheet.

MapTaxaObs(
  obs,
  xWalk,
  dirMain = getwd(),
  onlymatches = TRUE,
  dirData = "Data",
  dirGIS = "GIS",
  dirMaps = "Maps",
  verbose = TRUE
)

Arguments

obs

Excel file containing 3 columns: TaxaName, Latitude83, Longitude83

xWalk

Crosswalk (Excel file) of taxa names between taxa name in occurence file and file name outputs for maps. Three columns (CommonName, Species, MapName).

dirMain

Path for folder containing obs and xwalk. Optional. Default = getwd().

onlymatches

Flag for mapping obs taxa matching xwalk taxa, or all taxa. Optional. Default = TRUE.

dirData

Subdirectory of "dir" specified above with data files. Default = "Data"

dirGIS

Subdirectory of "dir" specified above with GIS files. Default = "GIS"

dirMaps

Subdirectory of "dir" specified above for map outputs. Default = "Maps"

verbose

Boolean value for including feedback to the user that the script is working. Default = TRUE.

Value

Saves the maps and a dataframe of observed taxa not matching xwalk taxa to the dirMaps folder.

Details

The example data is fish but can be used for benthic macroinvertebrates as well. Maps are output as PNG. There is a flag for "only" matches between the data and the crosswalk table (this is the default). There is also a "verbose" flag for printing status messages to the user (this is the default). Tests for existence of Data, GIS directories and required files. On failure, stops and prints missing directories/files to screen.

The R libraries rgdal, sf, and readxl are required for this function.

Examples

# Set Working Directory
wd <- tempdir()
# Create Example Data if Needed
## Create Directories
myDir.create <- file.path(wd, "Data")
ifelse(dir.exists(myDir.create) == FALSE
       , dir.create(myDir.create)
       , "Directory already exists")
#> [1] TRUE
myDir.create <- file.path(wd,"GIS")
ifelse(dir.exists(myDir.create) == FALSE
       , dir.create(myDir.create)
       , "Directory already exists")
#> [1] TRUE
myDir.create <- file.path(wd,"Maps")
ifelse(dir.exists(myDir.create) == FALSE
       , dir.create(myDir.create)
       , "Directory already exists")
#> [1] TRUE
## Create Data
### Taxa Data
myFiles <- c("AllFish_95to16.xls", "TaxaMapsCrossWalk20170731.xlsx")
file.copy(file.path(find.package("MBSStools", .libPaths())
         , "extdata"
         , myFiles),
file.path(wd, "Data", myFiles))
#> [1] TRUE TRUE
### GIS
unzip(file.path(find.package("MBSStools", .libPaths()), "extdata", "MD_GIS.zip")
      , exdir = file.path(wd, "GIS"))

# Inputs
obs     <- "AllFish_95to16.xls"
xWalk   <- "TaxaMapsCrossWalk20170731.xlsx"
dirMain <- tempdir()

# Create maps
MapTaxaObs(obs, xWalk, dirMain)
#> /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpYhlTHl
#> Reading layer `MD_State_Boundary' from data source 
#>   `/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmpYhlTHl/GIS' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 2 features and 9 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 185215.8 ymin: 24676 xmax: 570274 ymax: 230969.3
#> Projected CRS: NAD83 / Maryland
#> Reading layer `MD_Coast_Hydrology' from data source 
#>   `/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmpYhlTHl/GIS' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 1117 features and 9 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 218484.5 ymin: 25187.84 xmax: 575093.6 ymax: 228369.4
#> Projected CRS: NAD83 / Maryland
#> Reading layer `MD_Boundary_County_Detailed' from data source 
#>   `/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmpYhlTHl/GIS' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 24 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 185218.5 ymin: 25770.69 xmax: 570274.9 ymax: 230946.1
#> Projected CRS: NAD83 / Maryland
#> Saving map 1 of 77; alewife.
#> Saving map 2 of 77; american eel.
#> Saving map 3 of 77; american shad.
#> Saving map 4 of 77; banded darter.
#> Saving map 5 of 77; banded killifish.
#> Saving map 6 of 77; black crappie.
#> Saving map 7 of 77; blacknose dace.
#> Saving map 8 of 77; blue ridge sculpin.
#> Saving map 9 of 77; blueback herring.
#> Saving map 10 of 77; bluehead chub.
#> Saving map 11 of 77; bluegill.
#> Saving map 12 of 77; bluntnose minnow.
#> Saving map 13 of 77; brown bullhead.
#> Saving map 14 of 77; brown trout.
#> Saving map 15 of 77; central stoneroller.
#> Saving map 16 of 77; chain pickerel.
#> Saving map 17 of 77; channel catfish.
#> Saving map 18 of 77; common carp.
#> Saving map 19 of 77; common shiner.
#> Saving map 20 of 77; creek chub.
#> Saving map 21 of 77; creek chubsucker.
#> Saving map 22 of 77; cutlip minnow.
#> Saving map 23 of 77; cutthroat trout.
#> Saving map 24 of 77; eastern mudminnow.
#> Saving map 25 of 77; eastern silvery minnow.
#> Saving map 26 of 77; emerald shiner.
#> Saving map 27 of 77; fallfish.
#> Saving map 28 of 77; fantail darter.
#> Saving map 29 of 77; fathead minnow.
#> Saving map 30 of 77; flathead catfish.
#> Saving map 31 of 77; gizzard shad.
#> Saving map 32 of 77; golden redhorse.
#> Saving map 33 of 77; golden shiner.
#> Saving map 34 of 77; goldfish.
#> Saving map 35 of 77; green sunfish.
#> Saving map 36 of 77; greenside darter.
#> Saving map 37 of 77; inland silverside.
#> Saving map 38 of 77; largemouth bass.
#> Saving map 39 of 77; least brook lamprey.
#> Saving map 40 of 77; longear sunfish.
#> Saving map 41 of 77; longnose dace.
#> Saving map 42 of 77; margined madtom.
#> Saving map 43 of 77; mottled sculpin.
#> Saving map 44 of 77; mummichog.
#> Saving map 45 of 77; northern hogsucker.
#> Saving map 46 of 77; northern snakehead.
#> Saving map 47 of 77; pirate perch.
#> Saving map 48 of 77; potomac sculpin.
#> Saving map 49 of 77; pumpkinseed.
#> Saving map 50 of 77; quillback.
#> Saving map 51 of 77; rainbow darter.
#> Saving map 52 of 77; rainbow trout.
#> Saving map 53 of 77; redbreast sunfish.
#> Saving map 54 of 77; redear sunfish.
#> Saving map 55 of 77; redfin pickerel.
#> Saving map 56 of 77; river chub.
#> Saving map 57 of 77; rock bass.
#> Saving map 58 of 77; rosyface shiner.
#> Saving map 59 of 77; rosyside dace.
#> Saving map 60 of 77; satinfin shiner.
#> Saving map 61 of 77; sea lamprey.
#> Saving map 62 of 77; shorthead redhorse.
#> Saving map 63 of 77; silverjaw minnow.
#> Saving map 64 of 77; smallmouth bass.
#> Saving map 65 of 77; spotfin shiner.
#> Saving map 66 of 77; spottail shiner.
#> Saving map 67 of 77; striped bass.
#> Saving map 68 of 77; striped shiner.
#> Saving map 69 of 77; swallowtail shiner.
#> Saving map 70 of 77; tadpole madtom.
#> Saving map 71 of 77; tessellated darter.
#> Saving map 72 of 77; walleye.
#> Saving map 73 of 77; white crappie.
#> Saving map 74 of 77; white perch.
#> Saving map 75 of 77; white sucker.
#> Saving map 76 of 77; yellow bullhead.
#> Saving map 77 of 77; yellow perch.
#> There are 54 non-matching taxa names.
#>     The non-matches are saved in a table with the maps.