United States
Environmental Protection
Agency
EPA/600/R/13/067
May 2013
                      User's Guide and Metadata for WestuRe:
                      U.S. Pacific Coast Estuary/Watershed
                      Data and R Tools
Office of
Research & Development

National Health and
Environmental Effects
Research Laboratory

-------
  User's Guide and Metadata for WestuRe: U.S. Pacific

        Coast Estuary/Watershed Data and R Tools

 M.R. Frazier1, D.A. Reusser2, H. Lee II1, L.M. McCoy3, C. Brown1 and W. Nelson1

                               May 2013 (vl)


^.S. Environmental Protection Agency, Office of Research and Development, NHEERL,
Western Ecology Division, Pacific Coastal Ecology Branch, Newport, OR, 97365, USA

2U.S. Geological Survey, Western Fisheries Research Center, Newport, OR 97365, USA

34298 N Beaver Creek Rd, Seal Rock OR 97376


Disclaimer This document has been reviewed in accordance with U.S. Environmental Protec-
     tion Agency policy and approved for publication. Mention of trade names or commercial
     products does not constitute endorsement or recommendation for use.
Acknowledgments We would like to thank Jim Kaldy, Ted Dewitt, and Chris Janousek for
     helpful discussions that helped shape this project. The reviews from John Bauer and
     Laura Mattison greatly improved the final product. And, a special thanks to Jim Kaldy for
     beta-testing the tools.
Preferred citation for data/tools  M. R. Frazier, D. A. Reusser, H. Lee II, L. M. McCoy, C. Brown
     and W. Nelson. 2013. WestuRe: U.S. Pacific Coast estuary/watershed data and R tools.
     U.S. EPA, Office of Research and Development, National Health and Environmental Effects
     Research Laboratory, Western Ecology Division. EPA/600/R/13/067.
Cover credits The watercolor map is from Stamen Design (www.stamen.com) and was ob-
     tained using the R package "ggmap" (Kahle and Wickham 2013).

-------
CONTENTS                                                     U.S. EPA and USGS
Contents

1  Overview                                                                    3

2  The Data                                                                    5
   2.1  Estuary data	    5
   2.2  Watershed data	   10
   2.3  NOAA salinity zones	   12
   2.4  Climate data   	   13
   2.5  Area normalized freshwater flow	   14

3  The Tools                                                                   17
   3.1  Program requirements	   17
   3.2  Starting R	   17
   3.3  Input data	   18
   3.4  R tools	   20
   3.5  R terminology	   31
   3.6  Error messages	   32

4  Metadata                                                                   33

-------
1  OVERVIEW
                        U.S. EPA and USGS
1   Overview
    There are about 350 estuaries along the
U.S. Pacific Coast (U.S. Fish and Wildlife 2011).
Basic descriptive data for these estuaries, such
as their size and watershed area, are impor-
tant for coastal-scale research and conserva-
tion planning.  However, this information is
spread among many sources, making it diffi-
cult to find and standardize.  The goal of the
WestuRe Project is to provide  a framework to:
(1) make general descriptive data for estuaries
and their watersheds more accessible, and (2)
provide tools to make analyzing and visualiz-
ing these data easier.
    The WestuRe download includes  data
describing U.S.  Pacific  Coast estuaries and
their corresponding watersheds from north-
ern  Washington  (including  the region lo-
cated along the Strait of Juan de Fuca that
goes from Port  Townsend to Cape Flattery,
48.383°N) to southern California (Tijuana Estu-
ary, 32.557°N), excluding Puget Sound proper
and coastal islands (Fig.  1). The WestuRe data
currently include shapefiles of estuary and wa-
tershed polygons as well as CSV files summa-
rizing geomorphological  and climate data (Fig.
2, Section 2). The WestuRe tools help users
extract and view relevant  data using the sta-
tistical program R and Google Earth (Fig. 3,
Section 3).
    Potential applications of the data include:
   • Describing and comparing estuaries and
     watersheds at the landscape scale
   • Identifying relationships between estu-
     ary/watershed variables
   • Incorporating   estuary/watershed  at-
     tributes in models to predict species and
     habitat distributions
   • Classifying estuaries according to mor-
     phology, climate, and habitat (Lee and
     Brown 2009)

Figure 1:  Data includes estuaries along the
      U.S. Pacific Coast (yellow region).

-------
1  OVERVIEW
                               U.S. EPA and USGS
Figure 2: Overview of data (details provided in Section 2).
       Estuary       Watershed       Climate
   SHP& CSV files
SHP& CSV files
     CSV files
   We modified the geospatial NWI data
   (U.S. Fish a Wildlife 2011) to make it
   more conducive to estuary research
     by:(1) including only estuarine
   wetland habitats, and (2) assigning
   each habitat polygon an estuary ID so
   data for individual estuaries can be
       identified and compiled.

   In addition to the SHPfiles, a CSVfile
    includes estuarine: name, state,
         latitude, longitude,
     total/intertidal/subtidal area.
The U.S. EPA (Lee and Brown 2009)
 delineated watersheds to capture
  the entire drainage area of each
  estuary (i.e., Estuarine Drainage
Area, EDA). Coastal Drainage Areas
  (CDAs) that do not feed into an
   estuary were also identified.

In addition to the SHP file, a CSVfile
includes watershed: type and area.
Monthly climate data are available
 for: (1) sea surface temperature
 outside the mouth of the estuary
   (Payne et al. 2011); (2) air
 temperature at the mouth of the
 estuary (Thornton 2009): and, (3)
 precipitation and air temperature
data averaged over the watershed
  (PRISM Climate Group 2011).
    Screenshot of NWI Wetlands
  Mapper for Yaquina Estuary, OR.
    The WestuRe estuary data is
       derived from the NWI.

-------
2   THE DATA
                           U.S. EPA and USGS
Figure 3: Overview of WestuRe tools for obtaining and visualizing estuary/watershed data
       using the statistical program R and Google Earth (details provided in Section 3).
      Viewing the files generated by the WestuRe
       visualization tools in Google Earth. Output
       includes sample points, estuarine habitats,
            and watershed boundaries.
                                                     STEP1
                                              WestuRe tools require a user
                                                 provided CSV file with
                                              latitude/longitude coordinates.
                                                 Example CSV data file:
1 -12 01
1 -12 12
2 -12 08
3 -123 93
4 -12 01
1 -124.01
1_ -124.01
5 -124.04
1 -124.03
^m^^m
46.96
47.02
46.89
46.90
44.62
44.60
44.57
44.43
44.43
„«
3
5
2
4
15
2
5
12
                                                     STEP 2
                                               In R, run a couple lines
                                                  of EASY code
                                                 Behind the scenes
                                             R overlays the coordinate data
                                             on the WestuRe data to obtain
                                              sample specific habitat data
                                              and estuary/watershed data
                                              that can be viewed in Excel
                                                 and  Google Earth.
                            1 .Samples: Original data with appended
                             site specific data (NWI habitat,
                             estuary, etc.)
                                                                              xl-l -124.I
                                                                              xl-l -124.01 46.96 1  P280X E2AB/USN  E2

                                                                              X3-1 -114.12 47.02 3  P280X E2AB/USN  E2

                                                                              X3-2 -124.08 46.89 5  P280X  E1UBL   El
                            2.Estuary: Estuarine and watershed
                             data associated with sample data
                             P200X Estuary  OR
                                Vaquina

                                Grays
                                Harbor
                               x Estuary  WA
                            3.ClimateMonthlv: Monthly climate data
                             for watersheds and estuaries
P2(]0x
PZlOx
pzao«

Feb
Mar
332.ai
234.74
245.67
1.39
2.37
2.89
2  The Data

     WestuRe provides data and tools for ana-
lyzing and visualizing estuary and watershed
data for the U.S. Pacific Coast (Table 1).  In
this guide, we provide a brief description of
the WestuRe data files and maps, and how they
were derived. Most of these data are updated
from the U.S. EPA report, Classification of Re-
gional Patterns of Environmental Drivers and
Benthic Habitats in Pacific Northwest Estuaries
(Lee  and Brown 2009). This  report invento-
ried the estuaries of the Pacific Northwest to
develop a classification scheme to better under-
stand the vulnerability of estuaries to anthro-
pogenic nutrient loading.  The Classification
Report provides a more comprehensive descrip-
tion of the data and how it may be used to help
assess estuarine vulnerability.
2.1   Estuary data
     The estuary geospatial  files and corre-
sponding estuary geomorphology data in the
WestuRe output are based on a modified ver-
sion  of the U.S. Fish  and  Wildlife Service's
National Wetlands Inventory data (NWI, U.S.
Fish  and Wildlife Service 2011).  The estu-
arine habitat data from  the NWI is an excel-
lent resource for analyses requiring regional
scale data  because  of its extensive and con-

-------
2   THE DATA
                                                           U.S. EPA and USGS
Table 1:  Files included in the WestuRe download.
  Data (folder)
Contents
                                                   Size
  EstMouths (folder)         Geospatial SHP and KML flies of estuary mouthpoints    N=349 estuaries +
                          based on NWP estuarine habitats                     2 Humboldt and 2 SF lobes'
  NWI_WA (folder)
Geospatial SHP file of estuarine habitats in Washington   N=1516 polygon features
  NWI_OR (folder)
Geospatial SHP file of estuarine habitats in Oregon
N=6698 polygon features
  NWI_CA (folder)
Geospatial SHP file of estuarine habitats in California    N= 10058 polygon features
  Watershed (folder)         Geospatial SHP and KML files of U.S. Pacific Coast
                          watershed boundaries
                                                   N=506 polygon features
  NOAAsalinity (folder)
Geospatial SHP and KML files of U.S. Pacific Coast
estuary salinity zones
N=36 estuaries (plus some
bays)
  EstuaryData (CSV)
Estuary data
N=349 estuaries +
2 Humboldt and 2 SF lobes'
  WatershedData (CSV)      Watershed data
                                                   N=506 watersheds +
                                                   Humboldt and SF combined
                                                   lobes
  ClimateMonthly (CSV)     Monthly climate data for watersheds and estuaries
                                                   N=508 x 12 months = 6108
  RFunctions (folder)
  Functions (R)
Code for points2est and points2kml tools that extend the
utility of the estuary/watershed data
  MapColors (CSV)         Color data for visualizing estuary habitat data (internal
                          file)
  Other Files
  ExampleData (CSV)
Example data used in SampleScript.R
  SampleScript (R)
Demonstration code for R tools
  SampleOutput (CSV)
Example output files generated by the points2est and
points2kml tools using "ExampleData.csv" data
  Users Guide (pdf)
PDF describing the data and R tools
  *NWI refers to the U.S. Fish and Wildlife Services' National Wetlands Inventory (U.S. Fish and Wildlife Service 2011).
  'Humboldt and San Francisco have additional data corresponding to their two estuary lobes.

-------
2  THE DATA
                        U.S. EPA and USGS
sistent geographic coverage.  The NWI pro-
vides regional-scale  maps of wetlands and
deepwater habitats which are classified us-
ing a hierarchical system organized as Sys-
tem/Subsystem/Class/Subclass plus some ad-
ditional modifiers (Cowardin et al. 1979, Ap-
pendix A). The habitat classes identified at the
system-level include marine, estuarine, river-
ine, palustrine, and lacustrine (Fig. 4). These
habitats are identified by analyzing high alti-
tude imagery in conjunction with other data
sources and field work. We modified the NWI
geospatial data for estuarine research by in-
cluding only habitat polygons classified as ma-
rine, estuarine,  and  tidal riverine. Further-
more, we assigned a unique Watershed ID to
each estuary habitat polygon, that identifies its
watershed (Section 2.2).
Figure 4: Screenshot of NWI Wetlands
      Mapper for Yaquina Estuary, OR.
    Following Lee and Brown (2009), estuar-
ies were defined as waterbodies containing an
NWI estuarine polygon and directly discharg-
ing into the ocean. Semi-enclosed harbors or
bays with only marine polygons and coastal
streams with only tidal riverine polygons were
not classified as estuaries.  The NWI was re-
vised in 2011, after the release of the Lee  and
Brown report, and several new estuaries were
identified, particularly in California where 78
estuaries were added.  One result of this revi-
sion is that there is no longer a strict one-to-
one correspondence between all estuaries  and
watersheds, and some coastal drainage areas
(CDA's) now contain one or more estuaries. For
most users, this will be of little consequence
because the newly added estuaries tend to be
very small with an average area of 0.03 km2.
To prevent confusion, WestuRe only includes
the estuarine area data for the 267 estuaries
with unique watersheds.
    Based  on our analysis of the NWI data,
there were 349 estuaries along the U.S. Pa-
cific Coast,  excluding Puget Sound, WA (Table
2). Descriptive statistics for each estuary were
obtained by summing the NWI estuarine habi-
tat polygons sharing the same watershed ID,
for: intertidal, subtidal, tidal riverine, and in
a few cases (based on best professional judg-
ment), marine habitats. There is just over 3600
km2 total estuarine habitat on the U.S. Pacific
Coast (including the estuaries along  the Strait
of Juan de Fuca, but otherwise excluding Puget
Sound). Extensive intertidal habitat is one of
                                          7

-------
2  THE DATA
                        U.S. EPA and USGS
the defining characteristics of U.S. West Coast
estuaries, with about 1380 km2, or 38%, of the
total estuarine habitat identified as intertidal.
Intertidal habitat provides many valuable ser-
vices including aquaculture and bird viewing
opportunities (Lamberson et al. 2011). About
65% of the inventoried estuaries were smaller
than 0.5 km2, and the 4 largest estuaries (San
Francisco,  Columbia River, Willapa Bay, and
Grays Harbor) account for about 83% of the
total estuarine area (Fig.  5).  Despite their
diminutive size, small estuaries are included in
these data because they provide critical habitat
for salmon (Lackey 2004, Lackey et al. 2006a,
2006b, Lawson et al. 2004), and have ecologi-
cal, economic, and cultural significance.

Table 2: Number of estuaries by state. Only
      estuaries with unique watersheds have
      estuary area data.
State
Washington2
Oregon
California
Columbia River3
Total
Estuary count
Unique
All watersheds1
40
64
244
1
349
38
62
166
1
267
Estuarine area
> 0.5 km2 > 1 km2
14
20
56
1
91
8
16
35
1
60
 Estuaries added in 2011 revision of NWI typically do not have a unique watershed
 2 Excludes Puget Sound
 3Washington and Oregon
    WestuRe provides the raw estuary data as
CSV and SHP files located in the "Data" folder.
The EstuaryData.csv file can be opened in Ex-
cel and contains descriptive spatial statistics
for each estuary (Table 8). The geomorpholog-
ical NWI habitat data are available as SHP files
(NWI_WA, NWI_OR, NWI_CA) which can be
visualized in Arc CIS, or other spatial software.
The estuary mouthpoints are available as ei-
ther a SHP or KML file (EstMouths). The KML
version can be viewed in Google Earth.  If the
points2est tool is run in R, these data will be
used to generate some of the data variables in
the "Samples.csv" (Table 4) and "Estuary.csv"
(Table 5) files that are returned. To generate
the estuary data in "Samples.csv", R overlays
the user provided sample points onto the NWI
data to obtain the estuary names and habitats
where the point falls.  For "Estuary.csv", the
descriptive data for estuaries that have sample
points are returned. If the points2kml tool is
run, maps of the estuarine habitat boundaries,
watershed boundaries, and sample points are
created for viewing in Google Earth.
    Despite the overall high quality of the
NWI data, there  are some limitations (Lee and
Brown 2009). Typically the NWI habitats are
not as detailed or as accurate as those from
habitat maps specifically developed for partic-
ular estuaries. The NWI habitat designations
for some estuaries are based on limited field
validation, and consequently, habitats may be
misclassified.  In particular, the designations
between estuarine and tidal riverine polygons
should be viewed cautiously. The demarcation
between estuarine and tidal riverine polygons
was defined by salinity, with the transition oc-
                                           8

-------
2  THE DATA
                        U.S. EPA and USGS
Figure 5: Distribution of estuary areas along the U.S. Pacific Coast (N=267). Most estuaries
      are smaller than 1 km2. The four largest estuaries are San Francisco, CA; Columbia River,
      OR/WA; Willapa Bay, WA; and Grays Harbor, WA (from largest to smaller).
             Estuaries < 15 km2
                 N = 254
                        L
                     a close-up
          0          50
          Smaller estuaries
                               100
                                            I
                                          150
                 -14
                 -12
                 -10
                 - 8
                 - 6
                 - 4
                 - 2
         200        250
           Larger estuaries
                                                                         01
                                                                         o
                                                                         o
                                                                         o
                                                                         o
                                                                         o  m
                                                                            ffl
                                                                            -3
                                                                         Ol
                                                                         O
                                                                         O
                               Estuary size ranking
curring where salinity exceeds 0.5 during the
period of annual average low flow. This bound-
ary can be difficult to accurately identify even
with ample field data, which is not available
for many of the estuaries. Furthermore, some
of the NWI data were generated in the late-
1970s and early-1980s, and thus are historical
snapshots of estuarine conditions.  Estuaries
are dynamic systems and the locations of their
mouths and habitats may have changed over
time. The habitat classification codes used by
the NWI may not always be consistent among
estuaries: in some cases, the codes may be
obsolete; in other  cases, the use of the more
detailed modifiers  is not consistent among es-
tuaries. For certain types of analyses, it may be
better to disregard the more detailed classifiers
or to consolidate the codes into broader habi-
tat classes as recommended by Lee and Brown
(2009, Table 2-1).  The U.S. Fish and Wildlife
Service has  an ongoing effort to update and
improve the NWI data so some of these issues

-------
2  THE DATA
                        U.S. EPA and USGS
will improve over time.                        tend to be very small  (average  size of 0.03
                                             km2), and consequently, the accurate delin-
2.2  Watershed data                           .    r       ,  ,      ,   ,.,.,..   .  ,
                                             eauon or watersheds may be difficult because
    The U.S. EPA (Lee and Brown 2009) delin-  the watershed areas tend to be overestimated
eated watersheds to create a one-to-one rela-  for estuaries smaller than <0.1 km2 (Lee and
tionship between each estuary and watershed  Brown 2009).
(Fig. 6). These data were derived from a wa-      About 506 EDAs and CDAs were identified,
tershed geospatial layer originally created for  with a total drainage area of 850,000 km2(and
NOAA's Coastal Assessment Framework (NOAA  308,000 km2 when the  Columbia River water-
1999).  Because the NOAA watershed bound-  shed is excluded) along the U.S. Pacific Coast
aries were not sufficiently detailed for estuary-  (Table 3).
scale analyses they were further delineated us-
ing additional data (Lee and Brown 2009). The
drainage area for each estuary was delineated
(Estuarine Drainage Area, EDA1) to capture the
entire landscape contributing to the nutrient
loading of the estuary. Coastal Drainage Areas
(CDA) that drain into the ocean but do not con-
Table 3: Summary of U.S. Pacific coast
      watersheds.
Watershed
Type
Estuary
Drainage
Area (EDA)
Coastal
Drainage
Area (CDA)


Definition Count

Watershed draining into a 256
single estuary

Watershed that does not drain 253
into an estuary, but due to a
recent update of the NWI, 39
CDAs contain one or more
small estuaries
Total Area
(km2)
437,625


7,890




tain an estuarine polygon were also identified
(Fig.6).
    The delineation of watershed boundaries
was based on estuaries identified in an earlier
version of the NWI data. Due to updates of the
NWI there are now a few mismatches between       In general, larger estuaries have larger wa-
the estuarine and  watershed geospatial data,   tersheds, with a general scaling relationship
Consequently, some estuaries are now located   of2:
within CDAs, which by definition should not       watershed ~ estuary°'rr
drain into an estuary. The WestuRe watershed       On  average,  an estuary that is twice as
data may be updated in the future to delineate   large as another will have a watershed that
watersheds  for the new estuaries.  However,   is about 70% larger (Fig.  7). Estuaries with
the estuaries without a dedicated watershed   relatively large watersheds for their size tend
  lrThis is equivalent to merging NOAAs Estuarine Drainage Area (EDA, portion of watershed that empties directly into the estuary
and is affected by tides) and Fluvial Dranage Area (FDA, portion of an estuary's watershed upstream of the EDA boundary) for an
estuary.
  2Reduced major axis regression model to allow for error in the independent variable (95% CI of 0.71-0.84, R2 = 0.51)
                                          10

-------
2  THE DATA
                        U.S. EPA and USGS
Figure 6: Watersheds of the U.S. Pacific Coast. Example of coastal drainage area (CDA) and
      the estuary drainage area (EDA) of Yaquina Estuary, OR.
to be more river-like; whereas, estuaries with
relatively small watersheds tend to be more
ocean-dominated. This is likely to have signif-
icant implications for an estuary's  biota and
susceptibility to certain types of stressors.  This
metric can be further refined by incorporat-
ing estimates of rainfall on the watershed (see
Section 2.5).
    WestuRe provides the raw watershed  data
as CSV and SHP files located in the  "Data"
folder. Watershed boundaries are available
as either a SHP or KML  file. The Watershed-
Data.csv file can be opened in Excel and con-
tains descriptive spatial statistics for each EDA
and CDA (Table 9). If the points2est tool is run
in R, these data are used to generate the water-
shed variables in the "Estuary.csv" file  (Table
5) that is returned.
    Some complexities of the watershed data
are worth noting. The Humboldt and San Fran-
cisco estuaries are both comprised of two es-
tuarine lobes with discrete watersheds. De-
pending on the analysis, it may be appropri-
ate to  treat these lobes as separate systems
and analyze them independently.  To  allow
the most flexibility, we provide data for the
individual lobes as well as for the combined
estuaries. Humboldt's  northern "Arcata Bay"
is supplied by watershed PI30x02 and south-
ern "Humboldt Bay" is supplied by watershed
PISOxOl. San Francisco's northern bay is sup-
plied by P090a and the southern bay by P090w.
The Columbia River watershed extends into
Canada, affecting the availability of some data
                                         11

-------
2  THE DATA
                        U.S. EPA and USGS
Figure 7: Relationship between estuary and watershed area. Estuaries above the line (e.g.
      Klamath and Rogue Rivers) tend to be more river dominated. Those below the line tend
      to be more ocean dominated (e.g. Humboldt and Netarts Bays).
                                      Estuary area, km
parameters. Specifically, the watershed climate
data for the Columbia River does not include
the Canadian region.

2.3  NOAA salinity zones
    We provide the salinity zones from NOAAs
Coastal Assessment Framework (NOAA 1999),
describing the average annual and depth aver-
aged salinity concentrations for 36 U.S. Pacific
Coast estuaries (plus some bays). These zones
drive the distribution of biological communi-
ties and contribute to the understanding of es-
tuarine circulation. The salinity concentrations
used to demarcate the zones were:  0.0-0.5
ppt = tidal fresh  zone; 0.5 to 25 ppt = mix-
ing zone; >25 ppt = seawater zone. The zone
boundaries were based upon salinity data from
published and unpublished sources as well as
discussions with experts.  The "best guess" of
informed experts was often necessary because
the data required to estimate the location of
these features were incomplete or nonexistent
(National Estuarine Inventory 1985). Salinity
zones are spatially and temporally variable due
                                         12

-------
2  THE DATA _ U.S. EPA and USGS

to factors that affect salt water intrusion and  Project (PFSST V50 and V51).  From these
fresh-water inflow such as tides, rainfall, and  data,  the USGS has created a data product
wind.                                     with monthly SST data for a >28 year period
    The NOAA salinity zone  maps are pro-  at a 4 km grid cell resolution for coastal re-
vided as SHP and KML files (Salinity Zones-  gions  within 20 km of the shoreline (Payne
NOAA). If the points2est tool is run, R overlays  et al.  2011).  From the USGS product, we
the coordinates of the user provided sample  extracted the SST data within 10 km of each
points onto the NOAA salinity zone map to ob-  estuary mouth and averaged the monthly val-
tain the salinity zone of each sample. These  ues for a 28 year period from 1982 to 2009.
data are included in the "Samples.csv" file that  Estuary ciimate data
is returned (Table 4).
                                              The monthly air temperature data (aver-
2.4  Climate data                            ^ mmimum) ancj maximum)  at the estu-
    Monthly climate data is summarized for:  ary mouth were estimated using Daymet data
sea surface temperature outside the mouth  (http://daymet.ornl.gov/gridded, Thorn-
of the estuary; air temperature at the mouth  ton 2009). Daymet is a model that generates
of the estuary; and air temperature and pre-  daily surface weather data using daily observa-
cipitation averaged over the watershed (Fig.  tions of minimum and maximum temperatures
8).  The raw  monthly climate data for all  and precipitation from ground-based meteo-
watersheds/estuaries are provided in  "Cli-  rological stations which are modeled over the
mateMontly.csv" in the "Data" folder.  If the  conterminous United States. Daymet provides
points2est tool is run in R, these climate data  daily climate data for the years 1980-2003 at
will be summarized for the estuaries contain-  a 1 km x 1 km resolution.  For each estuary, the
ing sample points and used to  generate some  daily climate data nearest the mouthpoint co-
of the data variables in the "Estuary.csv" (Table  ordinates were extracted. The daily data were
5) file that is returned.                      then averaged across all years for each month
Sea surface temperature (SST)             to calculate monthly means'
    The  average monthly surface tempera-  Watershed climate data
tures of the near-coastal waters of each estu-      The average  monthly  air temperature
ary mouth were estimated using satellite based  (average,  minimum,  and  maximum)  and
remote sensing observations from Advanced  cumulative monthly  rainfall was  estimated
Very High Resolution Radiometer (AVHRR).  for each  watershed using  PRISM  NOR-
These data were compiled into monthly means  MALS  climate  model data  (http: //prism.
as part of the Pathfinder versions 5.0 and 5.1  oregonstate.edu, Daly et al. 2007, PRISM

                                        13

-------
2  THE DATA	U.S. EPA and USGS

Climate Group 2011).  PRISM  (Parameter-  such as evaporation and percolation (Lee and
elevation Regressions on Independent Slopes  Brown 2009). Once in the estuary, the extent
Model)  uses point measurements of climate  that the freshwater mixes with ocean water is
data, elevation, and other data to produce con-  dependent partially on the volume of the  es-
tinuous digital grid estimates of monthly cli-  tuary. Ideally, cumulative annual precipitation
matic data. Hourly weather station data are  would be normalized by estuarine volume. In
used to determine the daily maximum and min-  the absence of these  data, estuary area is a
imum temperatures for a 24-h local period,  reasonable proxy for estuary volume (Lee and
These daily observations are then aggregated  Brown 2009). This index is calculated by the
to calculate the  monthly average maximum  points2est tool for each estuary that contains
and minimum  temperatures. The PRISM data  a sample point and is included in the "Estu-
provides monthly data averaged over 1971-  ary.csv" (Table 5) file that is returned.
2000 at a resolution of 30-arcsec (800 m). To      We used the  cumuiative volume of water-
average the climate data across the watershed,  shed rainfall to obtain an index for area nor.
we took the average of the raster cells within  malized freshwater flow because these data
each watershed polygon, weighting the values  are readily available for all estuaries  - includ-
by the percentage of each raster cell included  ing small) ungaged ones.  Moreover, despite
within the watershed  polygon.  The average  me coarseness of this index, it appears to suc-
air temperature was calculated by taking the  cessfully  capture key aspects  of tide- versus
mean of the minimum and maximum air tern-  river-domination as measured by salinity for
peratures (see  FAQ of PRISM website).         estuaries in the  Pacific Northwest (Lee and
                                           Brown 2009).  Estuaries  with low volumes
2.5  Area normalized freshwater flow
                                           of watershed rainfall relative to estuary area,
    One important variable that can be esti-  have less seasonal variation in salinity as well
mated using the WestuRe  data is an index for  as less variation  along the main axis of the
classifying tide-  and river-dominated estuar-  estuary.  Furthermore,  a positive relationship
ies which is calculated by  dividing the annual  was demonstrated between this index and the
cumulative volume of rainfall over the entire  variation in salinity over a tidal cycle at the
watershed (m3, PRISM climate data, Daly et al.  mouth of seven  target Pacific Northwest  es-
2007) by the area of the estuary (m2). Using  tuaries.  Despite  the advantages of this met-
the annual cumulative volume of rainfall on a  ric, estimates of freshwater flow derived using
watershed results in a correlated index of fresh-  gaged stations and/or models will be prefer-
water flow into the estuary because not all the  able in many instances because they provide a
water flows into  the estuary due to processes  direct estimate of freshwater flow (rather than

                                         14

-------
2   THE DATA
                            U.S. EPA and USGS
Figure 8:  Monthly climate data for representative U.S. Pacific coast estuaries.
         Waatch River Estuary
           Yaquina Estuary
          Rogue River Estuary
          Humboldt Bay Estuary
                      o


            Big River Estuary
                       o
               San Francisco Estuary


                           °

                               California


               Morro Bay Estuary o

            Canada Del Cojo  Estuary •

                 Los Angeles River Estuary *


                       San Diego Bay Estuary *
                                                                       Watershed Precipitation
                                                          o
                                                          o
 I*
 O)
 ?>
    O
    o
       Jan  Feb Mat Apr  May Jun  Jul Aug  Sep Get  Nov  Dec
                         Month
     20 -i
   U
   o

   0)
   O) -
   03

   0)
                  Estuary Air Temperature
     10 J
          Jan Feb  Mar Apr  May Jun  Jul Aug  Sep  Oct Nov  Dec
   22 -



   20 -



   18 -
0)  16 -
D)
to

t  14 H
   12 -



   10 -
                Sea Surface Temperature
                                                              Jan Feb  Mai Apr  May  Jun  Jul Aug Sep  Oct Nov  Dec
                           Month
                         Month
                                                   15

-------
2  THE DATA
                        U.S. EPA and USGS
a correlated index) and comparisons among
estuaries may be more accurate. However, this
method of estimating freshwater flow is not
entirely free of assumptions given that flow is
typically measured in a  single or limited num-
ber of an estuary's tributaries.
    Comparisons among  estuaries will  be
most appropriate when they are located within
the same  ecoregion because the percentage
of water that evaporates or percolates into
the soil will be  similar  for these watersheds,
such that a similar fraction of the rainfall will
flow into each estuary.  For example, most es-
tuaries in  the Pacific Northwest  are probably
comparable,  with the possible exception of the
Columbia River  due to the large size of its wa-
tershed. Caution should be applied when com-
paring estuaries from different ecoregions such
as Southern California and Pacific Northwest.
Despite this complication, these comparisons
may still be meaningful because  large differ-
ences in rainfall between these two regions
likely drive most of the variation in this metric.
    Lee and Brown (2009) used the follow-
ing preliminary thresholds to classify Pacific
Northwest estuaries:
   • Tidal-dominated: < 175 m3m~2 year"1
   • Moderately river-dominated: 175-400
     m3 m~2 year^1
                                    3 m-2
• Highly river-dominated: > 400 m3 m
  year"1
                                         16

-------
3  THE TOOLS	U.S. EPA and USGS


3   The Tools
    We have developed some tools to use within the statistical program R (R Development
Core Team 2011) to help researchers:
  1. associate their sample data to estuary and watershed data (points2est, Fig. 13)
  2. visualize these data in Google Earth (points2kml, Fig.  14).
The WestuRe data is available without these tools (located in the "Data" folder), however, the
tools provide a method of streamlining data acquisition and providing non-GIS experts with a
way to map their data and view it in the context of other datasets.
    These tools require the user to provide a dataset with latitude and longitude coordinates
for sample points located within one or more estuaries on the U.S. Pacific Coast. The points2est
tool aligns the sample coordinates with the geospatial watershed, NWI estuarine habitat, and
NOAA salinity zone data, in order to return data specific to the sample points and the estuaries
and watersheds where they are located (Tables 7, 9, 10). The points2kml tool takes an object
created by points2est and outputs KML files (i.e., Google Earth) of the original sample points,
NWI estuarine habitats, and watershed boundaries.
    The WestuRe download includes some additional files that demonstrate how these tools
are used.  The SampleScript.R file is an R file that includes all the code needed to  use the
points2est and points2kml tools. This file will need to be modified for the user's computer/file
configuration, the details of which are provided  below.  Also included is a sample  dataset
(ExampleData.csv) and the corresponding output files that are returned by the points2est and
points2kml tools (File "SampleOutput").
3.1  Program requirements
    The freeware statistical program R is needed to use the WestuRe tools. R can be down-
loaded from: http://cran.r-project.org/ (See:  Appendix B for installation instructions;
Section 3.5 for R terminology). The KML map files are viewed in Google Earth, which can be
downloaded from: http://www.google.com/earth/index.html.
3.2  Starting R
    When you open R, you will see a rather sparse "R Console" (Fig. 9). To confirm that R is
working, type 2 + 2 into the console and press enter:
                                         17

-------
3   THE TOOLS
U.S. EPA and USGS
2+2   #R returns  the  answer!
 [1]  4
   • The ">" is the "command prompt" where you input commands.

   • The cursor is R telling you that it is ready to do your bidding.

   • The output from R is blue and often preceded by a bracketed number.

   • Anything preceded by a # (green in many text editors) is a user comment that R ignores.
     This is used to document your work.

Figure 9: R console with some code entered (2 + 2).
             i- RGui (3J-bit)
             File Edit View  Misc Packages Windows  Help
             R version 2.15.1  (2012-06-22) — "Roasted Marshmallows"
             Copyright (C) 2012 The R Foundation for Statistical Computing
             ISBN 3-900051-07-0
             Platform: i336-pc-rcingw32/i336  (32-bit)

             R is free software and comes with ABSOLUTELY NO WARRANTY.
             You are welcome to redistribute it under certain conditions.
             Type 'license()'  or 'licence()' for distribution details.

               Natural language support but running in an English locale

             R is a collaborative project with many contributors.
             Type 'contributors()' for more information and
             'citation(}' on how to cite R or R packages in publications.

             Type 'demo()' for some demos, 'helpO1 for on-line help,  or
             •help.start()'  for an HTML browser interface to help.
             Type 'q()' to guit R.

             > 2-2
             [1] 4
             J
3.3   Input data
     The WestuRe tools require a user supplied dataset that includes latitudes and longitudes of
sample points from U.S. Pacific Coast estuaries. The data must be formatted as a CSV file (Fig.
10). A CSV file can be created from Excel using "Save As" and then selecting "CSV (Comma
delimited)(*.csv)" from "Save as type:".
                                              18

-------
3  THE TOOLS
U.S. EPA and USGS
    Latitude and longitude variables must be in decimal degrees. Methods of converting to dec-
imal degrees can be found online (example: http://en.¥ikipedia.org/¥iki/Geographic_
coordinate_conversion) and can be done in R using deg2num from the gmt package.  All
longitude coordinates should be preceded by a "-" (negative sign), to indicate the data are
located in the western hemisphere.
Correct format: 40.446195, -179.948862
Incorrect formats: 40°26'47"N, 79°58'36"W; 40:26:46N, 79:56:55W; 40.446195, 179.948862
Here are a few additional tips for preparing the CSV data file:
   • Column names should be concise and contain no spaces
   • Variables can be in any order, and there is no limit to the number of variables; however:
   • It is better to cut variables that include extensive notes because they can sometimes cause
     errors when importing into R and when displaying in Google Earth
   • Data with "#" symbols can cause import errors in R, and "&" symbols may cause errors in
     KML display

Figure 10: An example CSV file displayed in Excel that is ready for the WestuRe tools.
f
— -S Home Insert
A Cut
J 4l Copy
Paste
•r ^/ Format Painter
[ Clipboard ^
Page Layout Formulas Data R
Calibri -|ll -||A" AT|

B i n '||EEJ 'H'S** A"
Font ii
;:
                           Al
                                              Site


A
Site
2 xl-1
3 1x3-1
| 4 |x3-2
5 x3-3
6
7
S
9
10
11
17
x3-4
X4-1
X5-1
X5-5
X6-1

B
X
-124.011
-124.127
-124.08
-123.93
-124.016
-124.015
-124.012
-124.048
-124.034


C D E F
y richness
46.96969 1
47.0251 3
46.89846 5
46.9011 2
44.62429 4
44.60382 15
44.5784 2
44.43147 5
44.43147 12


                                        19

-------
3  THE TOOLS
U.S. EPA and USGS
3.4  R tools
    The SampleScript.R file provides a template that guides you through the process of using
the points2est and points2kml tools. To begin using the tools, open the SampleScript.R file in R:
open R -^File -^Open script...^ and find the SampleScript.R file located in the WestuRe folder.
This will open a 2nd window, called the text editor which will display some example code and
additional instructions for using the tools (Fig.  11). In the SampleScript.R file, information
proceeded by "#" are notes that are ignored by R, but provide useful information. To use the
points2est and points2kml tools, you will need to make a few changes to the SampleScript.R
file, which are described below. You will also need to be able to send lines of the code from the
SampleScript.R file to the R Console. To do this, place the cursor at the appropriate line in the
text editor and click the "Run line or selection" button (Fig. 11) or Ctrl+r.

Figure 11: R with SampleScript file open in the text editor window. Code is sent from the text
      editor window to the R Console by selecting the circled button.
STEP 0: Install packages
    If you have not already done so, you will need to install the following packages: rgdal, sp,
maptools (see Section 3.5 for a definition of "packages" and other terminology). These packages
were developed to do spatial analyses and are necessary for the points2est and points2kml tools
to work.
    To download a package, either: 1) From the upper menu in R select: Packages —>• Install
                                         20

-------
3  THE TOOLS	U.S. EPA and USGS

Packages; or, 2) go to the following line in SampleScript.R, and send the following code to the
R console:

install.packages(c(         ,      ,             ))

    R will ask which GRAN (Comprehensive R Archive Network) mirror site you want to use.
Select one that is nearby. R will automatically download the packages and save them to its
"library" folder located in the R Program Folder. You will only need to do this once, although,
you may want to update your packages fairly frequently because many developers are making
constant improvements.
STEP 1: Establish the directory path to the WestuRe folder
    You will need to tell  R the directory path for the WestuRe folder on your computer. In STEP
1 of the SampleScript.R, replace the existing directory path with the location of the WestuRe
folder on your computer.  Then,  send the code to the R console. Unless told otherwise, the setwd
(i.e., "set working directory") command established the location where R will search for and
save files.

setwd(                                   )

    NOTE: if you are using a Windows system, you will need to add an additional backslash
("\") between the folders in the directory path. Double backslashes are necessary because R
uses a single backslash as  an escape  character. Make sure that the pathway is enclosed by
quotes ("").
    The best approach for identifying the directory path is to copy and paste it from the address
bar that appears when you are within the WestuRe folder. This will help eliminate the mistakes
that inevitably occur when typing a long path (Fig. 12).
                                         21

-------
3  THE TOOLS
U.S. EPA and USGS
Figure 12: How to find a directory path in Windows systems.
                lie  Edit  View  Favorites  Tools Help
                       ,1   *  y- ' Search |j  Folders  IjjM"
                    C:\Doajments and 5ettings\mrrazi03\DesktQp\WestuRe_vlJ
                   To identify the path in R:
                   1) Open the relevant folder
                   2) Copy the path in the address window
                   3) Paste into R
                   4) Add  double back slashes if working in Windows:
                   C:\\Documents and Settings\\mfrazi03\\Desktop\\WestuRe_vl
STEP 2: Load the WestuRe tools
    Now, R must be told to read the functions.R file in the RTools folder. This file contains the
code for the points2est and points2kml tools. To make R read this file, send the following code
to the R Console:

source("\\RTools\\functions.R")
# Feedback should be  returned in the R
# Console: [1]  'estuary v.  1'  [1]
# 'Loading necessary  packages' Loading
# required package:....

STEP 3: Importing your data into R
    In STEP 3 of the SampleScript.R document, replace the existing directory path with the
location of the CSV file on your computer (Fig. 12). After the code is sent to the R Console, the
data will be imported into R and called "MyData". The <- symbol is used by R to assign a name
to an object, it can roughly be thought of as an equals sign.
                                          22

-------
3  THE TOOLS	U.S. EPA and USGS


MyData  <- read.csv(                                        )

    If you don't have any available data, but still want to try the tools, send the following code
to the R console:

MyData  <- read.csv(                   )

    In this case, R will import the "ExampleData.csv" file that is located in WestuRe folder.
    Once the data have been imported into R, it is critical to check that everything is correct. If
you have a short dataset, you can view all the data by typing the following into the R console:

MyData

    However, if you have a longer data file, it is better to use commands such as:

head(MyData)   # returns  first few lines  of data  frame  object
tail(MyData)   # returns  last few  lines  of data frame object
summary(MyData)  # returns summary  of  each variable
dim(MyData)  # returns number of  rows  and number  of columns

STEP 4: points2est
    The points2est tool (Fig. 13) aligns the user data with the spatial data and returns three
CSV data files:
Sample Original user data with appended data for each point describing the estuary name,
     watershed ID, NWI habitat, and NOAA salinity class (for select estuaries) (Table 4)
Estuary Estuary and watershed data for estuaries with sample points (Table 5)
Climate Monthly climate data for estuaries with sample points (Table 10)
The data in the CSV files are linked by the unique watershed ID variable (wsID).
                                         23

-------
                           User input
                                                                                              a
                                                                                              •S
                                                                                              1-!
                                                                                              n
                                                                                              H-»
                                                                                              to
                                                                                              D
                                                                                              O)
                                                                                                                                                                to
                                                    tfl
                                                    H
                                                    O
                                                    O
                                                    t-1
                CSV data file:
Usage:
to
Site
xl-1
x3-l
x3-2
x3-3
x3-4
x4-l
x5-l
x5-5
x6-l
X
-124.011
-124.127
-124.080
-123.930
-124.016
-124.015
-124.012
-124.048
-124.034
V
46.9696
47.0251
46.8984
46.9011
44.6242
44.6038
44.5784
44.4314
44.4314
SP
1
3
5
2
4
15
2
5
12
               Tips:
               • Latitude and longitude coordinates
                 must be decimal degrees
               • Variable (i.e. column) names should
                 be concise and have no spaces
               • Variables can be in any order and
                 there is no limit to the number of
                 variables
               • Variables with long notes may cause
                 import errors
               • CSV files are imported into R using
                 the read.csv function
            Example:
             MyData <-
             read. csv("C:\\My Pat n\\Exam pie Data, csv")
                                                         points2est(x, lat, Ion, climate=TRUE, FileName, saveDir)
1.  Sample: Original data with newly
   appended estuary habitat data
                                                                                                             Site
                                                                              NWI   NWI
                                                                       sp wsID code  short
                                                                              E2AB/
Arguments:
X


Name the CSV file was given when
imported into R. Example: MyData
data. Example: lon="x"
xl-l -124.011 46.9696 1 P280x USN
E2AB/
t/AB/
x3-l -124.127 47.0251 3 P280x USN
X3-2 -124.08 46.8984 5 P280x E1UBL

E2
E2
El
...
-hoH
  lat         Name of the latitude variable in the
             data. Example: lat="y"

  climate     Logical. If TRUE, climate data is returned

  FileName   The name that will be given to the
             output data files. Example: FileName =
             "SamplesFeb2013"

  saveDir     Directory path that describes where to
             save output data . This should refer to an
             existingfile on your computer.  Example:
             saveDir = "C:\\MyPath\\EstuaryData"
                                                        Example:
  EstData <- points2est(x=MyData, lon="x", lat="y"
  climate=TRUE, FileName="SamplesFeb2013",
  saveDir="C:\\MyPath\\EstuaryData")
   data  associated with sample data
               est     est
   wsID estName State Longitude
         Alsea
   PZOOx Estuary  OR   -124.07
        Yaquina
   P210x Estuary  OR   -124.06
         Grays
        Harbor
   P280x Estuary  WA   -124.14
3.  ClimateMonthly: Monthly climate
   data for watershed and estuaries
                    wsTair
   wsID  month wsPPT   min
   P200x  Jan  332.41   1.39
   P200x  Feb  284.74   2.37
   P200X  Mar  245.67   2.89
                                                                                                            4.  Object used by points2kml
o
!3
O
                                                                                                                                                      o
                                                                                                                                                      3'
                                                                                                                                                      O
                                                                                                                                                      O
                                                                                                         C
                                                                                                         C/3
                                                                                                         tfl
                                                                                                                                                                C
                                                                                                                                                                (X)

-------
3  THE TOOLS	U.S. EPA and USGS

    An example of the points2est tool:

EstData <- points2est(x = MyData, Ion =     ,
    lat =    , climate  = TRUE, FileName  =
    saveDir =                           )

    The arguments are:
   1. x = name of the data  imported into R. Example: MyData (STEP 3)
   2. Ion = name of the longitude variable in the data. Example: Ion = "x"
   3. lat = name of the latitude variable in hte data. Example: lat = "y"
   4. climate = TRUE/FALSE, if TRUE climate data are returned
   5. FileName = a name for the output files. Example: FileName="SamplesFeb2013"
   6. saveDir = directory path describing where to save output files. Example: "C:\\MyPath\\EstuaryData"
In the above example, points2est  generates 3 CSV data files that are saved in the directory:
"C:\\MyPath\\EstuaryData". In addition to these files, points2est creates an object that includes
all the relevant geospatial data. In this case, the  object is named "EstData". You do not need to
know anything about this object except that it can be used by the points2kml tool to create KML
maps of the data.
                                        25

-------
3  THE TOOLS
                                                  U.S. EPA and USGS
Table 4: "Sample" is a CSV data file generated by points2est that includes the following
      variables that are appended to the original data.
   Variable
Description
Origin
   wsID
ID of the watershed where the sample point is
located
Modified from Lee and
Brown (2009)
   SalinityZone  Salinity zone where the sample point is located
                                            NOAA's Coastal
                                            Assessment
                                            Framework
   estName      Name of the estuary where the sample point is
                located
                                            Derived by overlaying
                                            sample data on NWI
                                            geospatial data layer
   NWIcode     The NWI habitat class at the location of the
                sample point
                                            Derived by overlaying
                                            sample data on NWI
                                            geospatial data layer
   NWIshort     The first two characters of the NWI habitat
                class.
                   • El = estuarine subtidal habitat
                   • E2 = estuarine intertidal habitat
                   • Ml = marine subtidal habitat
                   • M2 = marine intertidal habitat
                   • Rl = tidal river habitat
                   • NA = does not fall within an NWI
                     estuarine polygon
                                            Derived from the NWI
                                            geospatial data
                                         26

-------
3   THE TOOLS
                                                        U.S.  EPA and USGS
Table 5: "Estuary" CSV data file generated by points2est. NOTE: Estuary data is not returned
       in the few cases when there is more than one estuary in a watershed.
 Variable
Description
Origin
 wsID
ID of the watershed where the sample point is located    EstuaryData.csv (Table 8)
 estName
Name of the estuary
EstuaryData.csv (Table 8)
 estState
State in which estuary is located (WA, CA, OR)
EstuaryData.csv (Table 8)
 estLongitude
Longitudinal coordinate of estuary mouthpoint
(decimal degrees)
EstuaryData.csv (Table 8)
 estLatitude
Latitudinal coordinate of estuary mouthpoint (decimal
degrees)
EstuaryData.csv (Table 8)
 estArea
Total area (m2) of estuarine habitat within each
watershed, calculated by summing the area of NWI
polygons:  El, E2, Rl, and occasionally, M2 (based on
best professional judgment).
EstuaryData.csv (Table 8)
 subtidalArea
Total area (m2) of subtidal (El) NWI polygons within
an estuary
EstuaryData.csv (Table 8)
 intertidalArea
Total area (m2) of intertidal (E2) NWI polygons within
an estuary
EstuaryData.csv (Table 8)
 marineArea
Total area (m2) of marine (M2) NWI polygons within
an estuary. Typically, marine habitat was not included
as part of estuarine area with the exception of a few
bays. The decision to include M2 area was based on
best professional judgment.
EstuaryData.csv (Table 8)
 riverArea
Total area (m2) of tidal influenced rivers (Rl) NWI
polygons within an estuary
EstuaryData.csv (Table 8)
 estNotes
                         Comments related to data
                                                   EstuaryData.csv (Table 8)
 Continued on next page..
                                                  27

-------
3   THE TOOLS
                                                         U.S. EPA and USGS
Table 5: ....Continued
 Variable                Description
                                                   Origin
 wsType
Describes relationship between watersheds and
estuaries:
EDA Estuarine drainage area, watershed delineation is
     defined by an estuary
CDA Coastal drainage area. These typically do not
     contain an estuary. However, a few now include
     one or more estuaries due to revision of the NWI
When estuaries are located in a CDA, watershed
data may not be meaningful.
WatershedData.csv (Table 9)
 wsArea
Area of watershed (m2)
WatershedData.csv (Table 9)
 wsNotes
                         Comments related to data
                                                   WatershedData.csv (Table 9)
 wsPPT cumulative
Cumulative yearly precipitation (mm) averaged over
the watershed. Calculated by summing the average
monthly rainfall data.
Derived from
ClimateMonthly.csv (Table
10)
 AreaNormFreshFlow
Area normalized freshwater flow (m3 m  2 year :).
Relative measure of freshwater flow through the estuary
based on watershed precipitation data and estuary size.
This variable is calculated by dividing the annual
cumulative volume of rainfall over the entire watershed
(m3) by the area of the estuary (m2), or
(wsPPT^cumulative x 0.001 x wsArea) / estArea. See
section on "Area-normalized freshwater flow" for more
details.
Derived from
ClimateMonthly.csv (Table
10)
 wsTair_YearMean         Annual mean air temperature (°C) averaged over the
                         watershed. Calculated by averaging the monthly
                         watershed air temperature data.
                                                   Derived from
                                                   ClimateMonthly.csv (Table
                                                   10)
 estTair_YearMean         Annual mean air temperature (°C) near the estuary
                         mouth. Calculated by averaging the monthly estuary air
                         temperature data.
                                                   Derived from
                                                   ClimateMonthly.csv (Table
                                                   10)
 estSST_YearMean         Annual mean sea surface temperature (°C) outside the
                         estuary mouth within a 10 km radius. Calculated by
                         averaging the monthly sea surface temperature data.
                                                   Derived from
                                                   ClimateMonthly.csv (Table
                                                   10)
                                                  28

-------
3  THE TOOLS	U.S. EPA and USGS

STEP 5: points2kml
    Points2kml (Fig. 14) uses the object created bypoints2est to create three KML map files
to display:  1) the sample points, 2) watershed boundaries, and 3) NWI estuarine habitat
classification. These KML files can be opened in Google Earth (as well as ArcGIS software).
                      To use points2kml, it is necessary to first run points2est.
    An example of the points2kml tool:

points2kml(x = EstData, kmlWS = TRUE, kmlNWI  =  TRUE,
    IDvar =       , FileName  =                  ,
    saveDir =                           )

    The arguments are:
  1. x = name of the object created by points2est (In STEP4, this was: "EstData")
  2. kmlWS = TRUE/FALSE, if TRUE a watershed KML file will be created
  3. kmlNWI = TRUE/FALSE, if TRUE a NWI estuary KML file will be created

  4. IDvar = name of variable (i.e., column) in the original data that identifies samples. These
     data will be used to label the points on the KML file (this can be left blank). Example:
     IDvar = "Site"
  5. FileName = a name for the output data files. Example: FileName = "SamplesFeb2013"
  6. saveDir = directory path describing where to save output maps.  Example: saveDir =
     "C:\\MyPath\\EstuaryData")
In the above example, points2kml generates 3 KML data files that are saved in the directory:
"C: \\MyPath\\EstuaryData". If Google Earth is installed, you can visualize your data by double
clicking on the newly created KML files.
    There are a couple known issues with the points2kml tool. It can take a very long time if
many complex estuaries are being saved to the KML file. In some cases, symbols such as "&"
within the original data files may prevent the creation of the KML file. Holes in polygons are
not displayed correctly in the  KML file (but are otherwise interpreted correctly).
                                        29

-------
00
O
             The points2est tool must first be run,
             in order to create an object that is
             used by the po!nts2kml tool.

             Example:	
             EstData <- ooints2est(x=MyData,
             lon="x", lat="y", climate=TRUE,
             FileName="SamplesFeb2013",
             saveDir="C:\\MyPath\\EstuaryData")
             In this example, the object that is
             passed to the po/nts2/
                                                                                                 VI
                                                                                                 3.
                                                                                                 CJ.
                                                                                                 o
                                                                                                 o
                                                                                                 3'
                                                                                                 F
                                                                                                 ISO
O
O
                                                                                                                                                             oo
                                                                                                                                                             tfl
                                                                                                                                                             H
                                                                                                                                                             O
                                                                                                                                                             O
                                                                                                                                                             t-1
                                                                                                           C
                                                                                                           in
                                                                                                           tfl
                                                                                                                                                             C
                                                                                                                                                             oo
                                                                                                                                                             in

-------
3  THE TOOLS	U.S. EPA and USGS

Leaving R
    When you finish working in the R text editor, save the script (File ->• Save As). You can
then reopen the script at a later date and rerun the analysis. When closing R, you will get this
message: save  workspace image?  [y/n/c]. You will probably want to choose the V option. If the "y"
option is chosen, all the R objects (".RData" file) and commands (".Rhistory" file) from your
session will be saved to the working directory. I typically find this unnecessary,  because the
R script preserves the steps for redoing the analyses in a more organized fashion. Option "c"
cancels the shutdown. If you continue using R, you will eventually want to transition to a text
editor, such as RStudio (http: //rstudio. org/). Text editors designed to work  with .R files
offer many advantages such as color coding and indenting of code to make it easier to read.
3.5  R terminology
GRAN The Comprehensive  R Network: A network of FTP and Web servers around the world
     that store identical, up-to-date, version of R code and documentation.
Function An  object that includes the code needed by R to perform a particular task. Examples
     include: mean, source,  and  read.csv. The points2est and points2kml tools are  functions.
Packages Text files that contain code (i.e., functions) that give R its functionality. For many
     programs everything is included in the initial installation. R works differently. When you
     install R on your computer, it includes the program and a set of "base" packages. Every
     time you open R, these "base" packages are automatically read into R. In addition to these
     "base" packages, 1000s of additional packages are available from the CRAN website for
     more specialized operations. These packages are not automatically downloaded with R,
     but you can download them yourself. For a list of available packages, follow the "Packages"
     link at [{http: //cr}] an. r-pro j ect. org/.
Working directory The working directory is the location on your computer that R is working
     from; or in other words, the location where R reads and saves files. The R command for
     defining the working directory is setwd.
                                         31

-------
3   THE TOOLS
                               U.S. EPA and USGS
3.6   Error messages
Table 6:  Possible errors from the points2est and points2kml.
  Error
Action
  data points removed due to missing
  latitude/longitude
Some sample points did not contain complete location
information. You can ignore this error if you are already
aware of this issue.
  data points appear to be outside the geographic  Some sample points are located outside the U.S. Pacific
  extent, you may want to check this!             Coast. You can ignore this error if you are already
                                              aware of this issue.
  cannot open file—
The directory pathways are not correct which is
preventing data from being accessed or saved. Check
the directory pathways. Check that double back
slashes are used to separate folders.
  Longitude coordinates should be negative
The longitude coordinates for the U.S. Pacific coast
must be negative.
  Longitude/Latitude contains non-numeric data
The longitude/latitude coordinates contain
non-numeric characters. These data must be identified
and replaced.
  No data are located in NWI estuaries
The data are located along the U.S. Pacific coast but not
within an estuary. This could occur if data are located
along the coast, but not in an estuary. Or, if data fall
just outside the NWI estuary boundaries.
  KML file is created, but will not display when
  opened in Google Earth
Some characters in the original user input data may be
causing the KML file to break. Note the error line that is
reported and open the KML file in a text editor to
determine what might be causing the error. Replace this
character in the original CSV file. Cut long notes from
input file.
                                               32

-------
4   METADATA
                                                     U.S. EPA and USGS
4  Metadata
    The following tables describe the variables in the: EstuaryData.csv (Table 8); Watershed-
Data.csv (Table 9); and ClimateMontly.csv data (Table 10).

Table 7: Description of geospatial data files. All spatial data is in projection WGS 84.
      Data file
Format
Description
      NWI_WA
      NWI_OR
      NWI CA
polygon SHP files
Estuary habitat delineations based on NWI (U.S. Fish
and Wildlife Service 2011). These data including only
estuary-related polygons (estuarine, marine, and tidal
river). A unique watershed identifier was added to each
NWI habitat polygon to identify polygons in the same
estuary.
      Watershed
polygon SHP and
KML file
Watershed delineations for US Pacific Coast estuaries
and coastal drainage areas (Lee and Brown 2009). Each
watershed polygon has a unique identifier. There is a 1-1
correspondence between most watersheds and estuaries.
However, a few watersheds include more than one
estuary due to recent updates of the NWI. These
watersheds/estuaries are identified in the database.
Note: Humboldt is composed of two watersheds
(P130x02 N, "Arcata Bay"; PISOxOl S, "Humboldt Bay")-
San Francisco is composed of two watersheds (P090a N;
P090wS).
      EstMouths     point SHP and      Point locations near the estuary mouth midpoints.
                   KML file            NOTE: Estuaries are dynamic and unjettied estuary
                                      mouths can and do move.
      NOAAsalinity  polygon SHP and
                   KML file
                  NOAA salinity zones for 36 U.S. Pacific coast estuaries
                  (plus some bays):
                  tidal fresh zone = 0.0-0.5 ppt
                  mixing zone =  0.5 to 25 ppt
                  seawater zone  =  > 25 ppt
                  If data are unavailable, NA values are returned.
                                             33

-------
4   METADATA
                                                                 U.S. EPA and USGS
Table 8: Description of estuary data variables (EstuaryData.csv). For more information see
       section 2.1.
  Variable name   Description
                                                    Origin
  wsID
Unique ID of watershed where estuary is located
Modified from Lee and Brown (2009)
  estName
Name of estuary
Modified from Lee and Brown (2009)
  estState
State of estuary location (WA, CA, OR)
Based on comparisons of NWI estuary
polygons with state boundaries in
Google Earth
  estLongitude      Longitudinal coordinate of estuary mouthpoint (decimal
                  degrees)
                                                    Midpoint of estuarine mouthpoint
                                                    estimated from Google Earth
  estLatitude       Latitudinal coordinate of estuary mouthpoint (decimal
                  degrees)
                                                    Midpoint of estuarine mouthpoint
                                                    estimated from Google Earth
  estArea
Total area (m2) of estuarine habitat within each
watershed. Typically, a watershed includes only one
estuary. However for a few smaller estuaries, more than
one estuary is located within a watershed due to recent
revisions of the NWI. In these cases, estArea is not
provided. Watersheds with more than one estuary can
be identified by the estCount variable in the
WatershedData.csv data; estuaries with a wsID that
corresponds to watersheds with estCount > 1 share the
watershed with other estuaries.
Calculated from NWI geospatial data
  subtidalArea     Total area (m2) of subtidal (El) NWI polygons within an  Calculated from NWI geospatial data
                  estuary
  intertidalArea
Total area (m2) of intertidal (E2) NWI polygons within    Calculated from NWI geospatial data
an estuary
  marineArea      Total area (m2) of marine (M2) NWI polygons within an  Calculated from NWI geospatial data
                  estuary. Typically, marine habitats were not included in
                  estuarine area. However, they were included in a few
                  cases, such as in some bays. Decision to include M2
                  areas were based on best professional judgment and
                  data availability.
  riverArea
Total area (m2) of tidal influenced river (Rl) NWI
polygons within an estuary
Calculated from NWI geospatial data
  estNotes
                  Comments related to data
                                                  34

-------
4  METADATA
                                                 U.S. EPA and USGS
Table 9: Description of watershed data (WatershedData.csv). For more information, see
      section 2.2.
 Variable Name  Description
                                         Origin
 wsID
Unique watershed identifier
Modified from Lee and
Brown (2009)
 wsType
Describes relationship between watersheds   Based on comparisons of
and estuaries (Fig. 6):                      watershed and estuary
                                         SHP files
EDA Estuarine Drainage Area. Watershed
     delineation was defined by an estuary.

CDA Coastal Drainage Area. These typically
     contain no estuary; however, in some
     cases, they may include one  or more
     estuaries due to revision of NWI after
     watersheds were delineated. This is
     not an issue for larger estuaries.
 estCount
Number of estuaries in the watershed.
Typically CDAs will have no estuaries and
EDAs will have 1 estuary. However, this is
not always the case due to the recent
update of the NWI.
Modified from Lee and
Brown (2009)
 wsArea
Area of watershed (m2)
Calculated from
geospatial data
 wsNotes
Comments related to data
                                         35

-------
4  METADATA
                                                       U.S. EPA and USGS
Table 10: Description of climate data. For more information, see Section 2.4.
  Variable name  Description
                                             Origin
  wsID
Unique watershed identifier
Modified from Lee and Brown
(2009)
  month
Month of temperature data (Jan-Dec)
  Watershed climate data
wsPPT
wsTair min
wsTair max
wsTair avg
Monthly average of cumulative precipitation
(mm) averaged over the watershed area.
Monthly average of minimum daily temperature
(°C) averaged over the watershed area
Monthly average of maximum daily temperature
(°C) averaged over the watershed area
Average of monthly minimum and maximum
temperature (°C) and then averaged over the
watershed area (as described in FAQ of PRISM
website)
PRISM (Daly et al. 2007)
monthly climate data averaged
from 1971-2000 at resolution
30-arcsec, or 800m
  Estuary climate data
  estTair_ min     Monthly average of daily minimum air
                 temperatures (°C) near estuary mouth
  estTairjnax     Monthly average of daily maximum air
                 temperatures (°C) near estuary mouth
  estTair_avg      Monthly average of daily average air temperature
                 (°C) near estuary mouth
                                             Daymet (Thornton 2009) daily
                                             climate data from 1980 to
                                             2003 at resolution of 1 km
                                             Daymet
  estSST
Monthly sea surface temperatures (SST, °C)
averaged over a 28 year period (1982-2009; 1981
was excluded because it did not include the entire
year) within 10 km of the estuary mouth
Monthly sea surface
temperature data averaged
over a 28+ year period
(1981-2009) from AVHRR
satellite based remote sensing
observations at 4 km resolution
and within 20 km of shoreline
(Payne  et al. 2011)
                                            36

-------
4  METADATA	U.S. EPA and USGS


References
Cowardin, L. M., V. Carter, F. C. Golet, E. T. LaRoe. 1979. Classification of wetlands and deep-
     water habitats of the United States. U. S. Department of the Interior, Fish and Wildlife
     Service, Washington, D.C. FWS/OBS-79/31.
Daly, C., J. I. Smith and R. McKane. 2007. High-resolution spatial modeling of daily weather
     elements for a catchment in the Oregon Cascade Mountains, United States.  Journal of
     Applied Meteorology and Climatology 46:1565-1586.
Dillon, M. E.  2011. University of Wyoming: Dillon: Teaching, http://www.uwyo.edu/mdillon/
     teaching.html (Apr 6, 2011) .
Kahle, D. and H. Wickham. 2013. ggmap:  A package for spatial visualization with Google
     Maps and OpenStreetMap. R package v. 2.3.
Lackey, R. T.  2004. A salmon-centric view of the twenty-first century in the western United
     States,  pp.  131-137, In P. Gallaugher and L. Wood (eds.)  Proceedings of the World
     Summit on Salmon, Simon Fraser University Burnaby British Columbia, Canada.
Lackey, R. T., D. H Lach and S. L. Duncan. 2006a.  Policy options to reverse the decline of
     wild pacific salmon. Fisheries 31:344-351.
Lackey, R. T., D. H. Lach and S. L. Duncan.  2006b. Salmon 2100: the future of wild salmon.
     American Fisheries Society Bethesda, MD.
Lamberson, J. O., M. R. Frazier, W. G. Nelson and P. J. Clinton.  2011.  Utilization patterns
     of intertidal habitats by birds in Yaquina Estuary, Oregon. U.S. EPA, Office of Research and
     Development, National Health and Environmental Effects Research Laboratory, Western
     Ecology Division, Newport OR. EPA/600/R-11/118.
Lawson, P. W., et al. 2004.  Identification of historical populations of Coho Salmon  (On-
     corhynchus kisutch) in the Oregon coast evolutionarily significant unit. U.S. Dept. Commer,
     NOAA Tech.  Memo. NMFS-NWFSC-79.
Lee II, H. and C. A. Brown (editors). 2009. Classification of regional patterns of environmen-
     tal drivers and benthic habitats in Pacific Northwest estuaries.  U. S. EPA, Office of Research
     and Development, National Health and Environmental Effects Research Laboratory, West-
     ern Ecology Division, Newport OR. EPA/600/R-09/140. http://nepis.epa.gov/Adobe/
     PDF/P1006Q2H.PDF

                                        37

-------
4  METADATA	U.S. EPA and USGS

National Estuarine Inventory. 1985. Data atlas: volume 1: physical and hydrologic charac-
     teristics. U.S. Dept of Commerce, National Oceanic and Atmospheric Administration,
     National Ocean Service.
NOAA. 1999. Coastal assessment framework.  NOAA/NOS/SPO, Silver Spring, MD. http:
     //coastalgeospatial.noaa.gov
Payne, M. C., D. A. Reusser, H. Lee II and C. A. Brown. 2011. Moderate-resolution sea sur-
     face temperature data for the nearshore North Pacific. U.S. Geological Survey Open-File
     Report 2010-1251. http://pubs.usgs.gov/of/2010/1251/ (downloaded Apr 4 2011)
PRISM Climate Group.  2011.  PRISM climate data.  Oregon State University, Corvallis, OR.
     http: //¥¥¥. prism. oregonstate . edu (downloaded Dec 2 2011)
R Development Core Team.  2011. R: A language and environment for statistical computing.
     R Foundation for Statistical Computing, Vienna, Austria, http: //www. R-proj ect. org/
Thornton, P. 2009. Daymet single-point data extraction users guide. University of Montana,
     Numerical  Terradynamic Simulation Group, http://daymet.org (downloaded Oct 18
     2011)
U.S. Fish and Wildlife Service. 2011.  National wetlands inventory website.  U.S. Depart-
     ment of the Interior, Fish and Wildlife Service, Washington, D.C. http: //www. fvs. gov/
     wetlands/ (state data downloaded Apr 29, 2011)
                                       38

-------
4  METADATA
U.S. EPA and USGS
Appendix A

    National Wetlands Inventory wetlands and deepwater habitats hierarchical classification

system.

      u.
      «
      to
      <
      o
      CO

      <

      :::
      <
      I
      a:
      yj

      <

      a.
      yj
      :.,.,
      Q
      O
      Z
      <
      CO
      a
      z
      UJ
   lit
                                                              li
                                                              ID sr
                                         39

-------
4   METADATA
U.S. EPA and USGS
Appendix B
R Installation and Setup1
     Installing R is very easy, regardless of your operating system.
    •  Go to ¥¥¥.r-project.org, where you'll see the R homepage (Fig B.I).
    •  Click on download R, which will take you to the "CRAN mirrors" page.
CRAN refers to  the "Comprehensive R Archive Network". This is simply a bunch of computers
scattered around the world that keep exact duplicates of all the files associated with R. Select a
mirror that is geographically close to you - this is good for both the servers (reduced load) and
the users (reduced download times). You will do this again when you install packages.
Figure B.I: R project homepage
                I File Ml ten History Bookmarks Tool? Help
                I (g TSe R Project for Statistical Computing  | + ,
                 ^- _i
                 i re a I. I
                 What's new?
                                                                           ~Pl It
                                          The R Project for Statistical Computing
                               Getting Started:

                                • Ris a free software enviMHHHIMTm .-tic;d i: 0111]. utuig and giaphics It :cmi.ili?s anlrut.s "ti a-wle variety of TIMX platfoiK
                                 "Windows andMacOS fo download Rjlt-ase ch"o.-e your preferred <~B AN mirror
                                • R version 2.15.1 (Roasted Marshmsl.->v^) h:^ V=n rp.p^M on 2012-06-22.
                                • The R Journal Vol.4/1 is available
                                • inpH1 :()i;» t o:-:ila:e at Vrn.letbi'UJnvers-y. ^af.ivUe'Ifn-iersee. UJA..utie 12-15. 2nli
                                • useR! 2013. will take place at the University of Castfla-La Mancha, Albacete, Spain, July 10-12 2013. .
                              This server is hosted by the Institute For Statistics and Mathematics of the WU "Wien.
      After selecting a mirror, a download window will appear (Fig. B.2), which will look the
      same regardless of the mirror you choose.
  1From Michael Dillon's website: http://wwH.uwyo.edu/mdlllon/HoR.html
                                                40

-------
4  METADATA
U.S. EPA and USGS
   • Choose the link for your operating system from the Download and Install R box at the top.
     (Source code needs to be compiled, which is probably not something you are interested in
     doing).

For Windows, choose the base link, then Download R X.XX.X for Windows and double-click the
file to install.
Figure B.2: Download R for your operating system from a CRAN mirror.
1 Qj The Comnrerierisive R Archive Network +
^ ^ ti -tfir.r-protettorg
aiintviMCaamiM
^S\
^
Mirrors
What's new?
Task Views
Search
The R Journal
Software
R Sources
R Binaries
Other
Manuals
FAQs




eim-R«n


^^Jju.^.—^^^.-^..^
| • Download R For Linux
1 • Download P. for MacOS X 1
Ris part of many Linux distributions, you should check with your Linux package management system in
Source Code for all Platforms
Windows and Mac -H*K mat hke.y v.'jnt to dov.:d iie piec'-mi-dei bji:in:3 ktec. in tne upper box, not the
• The latest release (2012-06-22, Roasted Marshmallows) R-2 15 1 tar gz. read what's new in the latest
• Sources of R alpha and beta relraff-- Mailv marft.ots rjpatpd f.iily ir. nnii= t'i=:if > '|i'-«ilr cvl ai'l nst;ill tne .'••'fhvjj:, >•! -A'liX th: kcnse terniL!
are. olease read our answers to freauentlv asked questions before you send an email


,-












                                        41

-------