Script was written by Matthew Harris, harri2mt@gmail.com Please email before using or changing script
Install and load required packages.
##Install and load the "easypackages" package to make loading other
#packages easier with the libraries function
#install.packages("easypackages")
library(easypackages)
#List the packages needed to be loaded for this script.
#Some packages may not be used due to changes to script
packages <- c("dplyr", "sf", "raster", "ggplot2", "stplanr", "rgeos", "geosphere", "ggmap",
"devtools", "rosm", "leaflet")
#install.packages(packages)
#install.packages(packages)
libraries(packages)
## Loading required package: dplyr
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Loading required package: sf
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
## Loading required package: raster
## Loading required package: sp
## Warning: no function found corresponding to methods exports from 'raster' for:
## 'direction', 'gridDistance'
## Error: package or namespace load failed for 'raster':
## Function found when exporting methods from the namespace 'raster' which is not S4 generic: 'all.equal'
## Loading required package: ggplot2
## Loading required package: stplanr
## Warning: no function found corresponding to methods exports from 'raster' for:
## 'direction', 'gridDistance'
## Error: package or namespace load failed for 'stplanr':
## Function found when exporting methods from the namespace 'raster' which is not S4 generic: 'all.equal'
## Loading required package: rgeos
## rgeos version: 0.5-9, (SVN revision 684)
## GEOS runtime version: 3.9.1-CAPI-1.14.2
## Please note that rgeos will be retired by the end of 2023,
## plan transition to sf functions using GEOS at your earliest convenience.
## GEOS using OverlayNG
## Linking to sp version: 1.4-6
## Polygon checking: TRUE
## Loading required package: geosphere
## Loading required package: ggmap
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
## Loading required package: devtools
## Loading required package: usethis
## Loading required package: rosm
## Loading required package: leaflet
##
## --------------------------------------------------
## The following packages did not load successfully:
##
Set Working Directory and bring in Downloaded data from The National Park Service, Environmental Protection Agency, and North Carolina Department of Environmental Quality.
Make basic edits to data to increase usability
#Set working directory to folder containing data sources
setwd("C:\\R Projects\\GRSM Map\\GRSM Data")
##Bring in Trails Data Shapefile from Project Folder
Trails <- st_read("Trails\\GRSM_TRAILS.shp")
## Reading layer `GRSM_TRAILS' from data source
## `C:\R Projects\GRSM Map\GRSM Data\Trails\GRSM_TRAILS.shp' using driver `ESRI Shapefile'
## Simple feature collection with 548 features and 79 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -83.94306 ymin: 35.4385 xmax: -83.04498 ymax: 35.78501
## Geodetic CRS: NAD83
#Look up coordinate system
st_crs(Trails)
## Coordinate Reference System:
## User input: NAD83
## wkt:
## GEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["latitude",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["longitude",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]]
##NAD83
##Bring in Trailhead Data from Project Folder
Trailheads <- st_read("Trailheads\\GRSM_TRAILHEADS.shp")
## Reading layer `GRSM_TRAILHEADS' from data source
## `C:\R Projects\GRSM Map\GRSM Data\Trailheads\GRSM_TRAILHEADS.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 154 features and 49 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -83.94025 ymin: 35.45354 xmax: -83.04498 ymax: 35.78501
## Geodetic CRS: NAD83
head(Trailheads)
## Simple feature collection with 6 features and 49 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -83.53818 ymin: 35.68554 xmax: -83.53164 ymax: 35.6914
## Geodetic CRS: NAD83
## EDITDATE CREATEDATE FACILITYTY ASSETCODE COUNTY LANDFORM MANAGEMENT
## 1 2020-11-14 2020-11-14 1110 1300 Sevier 5 <NA>
## 2 2020-11-14 2020-11-14 1110 1300 Sevier 5 <NA>
## 3 2020-11-14 2020-11-14 1110 1300 Sevier 7 <NA>
## 4 2020-11-14 2020-11-14 1110 1300 Sevier 9 <NA>
## 5 2020-11-14 2020-11-14 1110 1300 Sevier 6 <NA>
## 6 2020-11-14 2020-11-14 1110 1300 Sevier 5 <NA>
## MAPMETHOD WATERSHED LON LAT COORD_SYST
## 1 DERV West Prong Little Pigeon River Upper -83.53709 35.68554 GCS
## 2 DERV West Prong Little Pigeon River Upper -83.53762 35.68717 GCS
## 3 DERV West Prong Little Pigeon River Upper -83.53507 35.68803 GCS
## 4 DERV West Prong Little Pigeon River Upper -83.53818 35.68796 GCS
## 5 DERV West Prong Little Pigeon River Upper -83.53164 35.69043 GCS
## 6 DERV West Prong Little Pigeon River Upper -83.53530 35.69140 GCS
## DATUM UTM_ZONE X_COORD Y_COORD STATE UNITCODE QUADNAME
## 1 NAD83 17 270409.3 3952037 Tennessee GRSM GATLINBURG
## 2 NAD83 17 270366.7 3952220 Tennessee GRSM GATLINBURG
## 3 NAD83 17 270599.9 3952308 Tennessee GRSM GATLINBURG
## 4 NAD83 17 270317.6 3952309 Tennessee GRSM GATLINBURG
## 5 NAD83 17 270917.2 3952568 Tennessee GRSM GATLINBURG
## 6 NAD83 17 270588.5 3952683 Tennessee GRSM GATLINBURG
## PARKDISTRI
## 1 Little River District
## 2 Little River District
## 3 Little River District
## 4 Little River District
## 5 Little River District
## 6 Little River District
## NOTES FMSS_LOC
## 1 Derived from endpoint of trail where it meets road feature. <NA>
## 2 Derived from endpoint of trail where it meets road feature. <NA>
## 3 Derived from endpoint of trail where it meets road feature. <NA>
## 4 Derived from endpoint of trail where it meets road feature. <NA>
## 5 Derived from endpoint of trail where it meets road feature. <NA>
## 6 Derived from endpoint of trail where it meets road feature. <NA>
## FMSS_ASSET LOC_NAME ELEVATION
## 1 <NA> Fighting Creek Nature Trail Trailhead 1471.079
## 2 <NA> Fighting Creek Nature Trail Trailhead 1454.516
## 3 <NA> Old Sugarlands Trail Trailhead 1462.009
## 4 <NA> Cove Mountain Trail Trailhead 1448.623
## 5 <NA> Two Mile Lead Concession Horse Trail Trailhead 1455.722
## 6 <NA> Gatlinburg Trail Trailhead 1419.209
## ROAD TRAIL
## 1 Sugarlands Visitor Center Parking B Fighting Creek Nature Trail
## 2 Sugarlands Headquarters Parking C Fighting Creek Nature Trail
## 3 Newfound Gap Road North Old Sugarlands Trail
## 4 Sugarlands Residence Road Cove Mountain Trail
## 5 Sugarlands Riding Stables Parking Area Two Mile Lead Concession Horse Trail
## 6 Park Headquarters Road Gatlinburg Trail
## DMSLAT DMSLON DDMLAT DDMLON THEAD_TYPE
## 1 35° 41' 7.939" -83° 32' 13.534" 35° 41.1323100' -83° 32.2255740' Intepretive
## 2 35° 41' 13.811" -83° 32' 15.417" 35° 41.2301760' -83° 32.2569540' Intepretive
## 3 35° 41' 16.890" -83° 32' 6.238" 35° 41.2815060' -83° 32.1039660' Hiking
## 4 35° 41' 16.673" -83° 32' 17.458" 35° 41.2778880' -83° 32.2909740' Hiking
## 5 35° 41' 25.557" -83° 31' 53.892" 35° 41.4259500' -83° 31.8981960' Horse
## 6 35° 41' 29.030" -83° 32' 7.075" 35° 41.4838260' -83° 32.1179160' Hiking
## GlobalID PUBLICDISP DATAACCESS
## 1 eb8e8946-e309-4d04-9b25-762a008282ca Public Map Display Unrestricted
## 2 b282fe04-38bd-4bcb-8126-ea18f0e8a2f7 Public Map Display Unrestricted
## 3 77f0915a-23a5-4c0b-a1f0-90fc5d28e33f Public Map Display Unrestricted
## 4 f6683d4a-9167-42c8-b587-a59f36cf045c Public Map Display Unrestricted
## 5 f370b0d2-b87c-4b51-8fef-cdefa50a420d Public Map Display Unrestricted
## 6 a3146b3f-e4db-4f1a-a279-db8bbf75ed41 Public Map Display Unrestricted
## UNITNAME REGIONCODE CREATEUSER EDITUSER MAPSOURCE
## 1 Great Smoky Mountains National Park SER GRSM User GRSM User <NA>
## 2 Great Smoky Mountains National Park SER GRSM User GRSM User <NA>
## 3 Great Smoky Mountains National Park SER GRSM User GRSM User <NA>
## 4 Great Smoky Mountains National Park SER GRSM User GRSM User <NA>
## 5 Great Smoky Mountains National Park SER GRSM User GRSM User <NA>
## 6 Great Smoky Mountains National Park SER GRSM User GRSM User <NA>
## SOURCEDATE XYACCURACY ZACCURACY LOC_ID VALID_RESU IMARS_NAME IMARS_ID
## 1 1970-01-01 >=1m and <5m >=1m and <5m <NA> Certified <NA> <NA>
## 2 1970-01-01 >=1m and <5m >=1m and <5m <NA> Certified <NA> <NA>
## 3 1970-01-01 >=1m and <5m >=1m and <5m <NA> Certified <NA> <NA>
## 4 1970-01-01 >=1m and <5m >=1m and <5m <NA> Certified <NA> <NA>
## 5 1970-01-01 >=1m and <5m >=1m and <5m <NA> Certified <NA> <NA>
## 6 1970-01-01 >=1m and <5m >=1m and <5m <NA> Certified <NA> <NA>
## RVP_NAME OBJECTID geometry
## 1 <NA> 2 POINT (-83.53709 35.68554)
## 2 <NA> 3 POINT (-83.53762 35.68717)
## 3 <NA> 4 POINT (-83.53507 35.68803)
## 4 <NA> 5 POINT (-83.53818 35.68796)
## 5 <NA> 6 POINT (-83.53164 35.69043)
## 6 <NA> 7 POINT (-83.5353 35.6914)
#Look up coordinate system
st_crs(Trailheads)
## Coordinate Reference System:
## User input: NAD83
## wkt:
## GEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["latitude",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["longitude",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]]
##NAD83
##Bring in 3 Pass Depletion Data from Project Folder
ThreePass <- st_read("Fish 3Pass")
## Reading layer `GRSM_FISH_3_PASS_PT' from data source
## `C:\R Projects\GRSM Map\GRSM Data\Fish 3Pass' using driver `ESRI Shapefile'
## Simple feature collection with 552 features and 61 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -83.99099 ymin: 35.44901 xmax: -83.06021 ymax: 35.80502
## Geodetic CRS: NAD83
head(ThreePass)
## Simple feature collection with 6 features and 61 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -83.97437 ymin: 35.50098 xmax: -83.90568 ymax: 35.61786
## Geodetic CRS: NAD83
## PERMANENT_ EVENTDATE REACHCODE REACHSMDAT
## 1 {DEB5FEA5-43B0-44E9-8FA3-B7EB19179D2A} 2016-11-02 06010204000176 1899-12-30
## 2 {1E7BAC24-5213-45F2-9013-2387234DED06} 2016-11-02 06010204000606 1899-12-30
## 3 {D8C712FB-0FC7-4152-AD23-F0D9239FFD06} 2016-10-21 06010204000186 1899-12-30
## 4 {2F38FCC6-F4B9-428C-B924-A1C2641F10C4} 2016-11-03 06010204000608 1899-12-30
## 5 {A82CA609-5C39-4451-B6B4-809BF47CF30B} 2016-10-21 06010204000187 1899-12-30
## 6 {B0A64B3E-597B-4BA1-809C-EF106B60F351} 2016-11-02 06010204000179 1899-12-30
## REACHRESOL FEATURE_PE FEATURECLA SOURCE_ORI SOURCE_DAT SOURCE_FEA FEATUREDET
## 1 2 <NA> 2 <NA> <NA> <NA> <NA>
## 2 2 <NA> 2 <NA> <NA> <NA> <NA>
## 3 2 <NA> 2 <NA> <NA> <NA> <NA>
## 4 2 <NA> 2 <NA> <NA> <NA> <NA>
## 5 2 <NA> 2 <NA> <NA> <NA> <NA>
## 6 2 <NA> 2 <NA> <NA> <NA> <NA>
## MEASURE EVENTOFFSE EVENTTYPE MAPSOURCE SOURCEDATE EDITDATE QUADNAME
## 1 38.00778 NA 0 <NA> 1970-01-01 2020-11-14 CALDERWOOD
## 2 44.31893 NA 0 <NA> 1970-01-01 2020-11-14 CALDERWOOD
## 3 41.92498 NA 0 <NA> 1970-01-01 2020-11-14 CALDERWOOD
## 4 43.23154 NA 0 <NA> 1970-01-01 2020-11-14 CALDERWOOD
## 5 98.70543 NA 0 <NA> 1970-01-01 2020-11-14 CALDERWOOD
## 6 70.64877 NA 0 <NA> 1970-01-01 2020-11-14 CALDERWOOD
## UNITNAME COUNTY STATE X_COORD Y_COORD LAT LON
## 1 GRSM Blount Tennessee 230390 3938748 35.55563 -83.97437
## 2 GRSM Blount Tennessee 234024 3932194 35.50098 -83.92981
## 3 GRSM Blount Tennessee 234078 3944019 35.60613 -83.93448
## 4 GRSM Blount Tennessee 234773 3933027 35.50677 -83.92443
## 5 GRSM Blount Tennessee 236023 3945476 35.61786 -83.91410
## 6 GRSM Blount Tennessee 236560 3936679 35.53871 -83.90568
## WATERSHED STREAMNAME ELEVATION YEAR
## 1 Abrams Creek Lower Panther Creek 1043.819 <NA>
## 2 Chilhowee Lake Parson Branch 1446.712 <NA>
## 3 Abrams Creek Lower Abrams Creek 1098.024 <NA>
## 4 Chilhowee Lake Bible Creek 1635.226 <NA>
## 5 Abrams Creek Lower Abrams Creek 1175.929 <NA>
## 6 Abrams Creek Lower Panther Creek 2358.863 <NA>
## NOTES
## 1 Drive to Chilhowee Lake and use boat to proceed up Abrams Creek embayment to first major creek embayment entering on right. Panther Creek enters at end of embayment. Follow old manway roughly 0.75 miles to site.
## 2 DRIVE ON RT 321 TO FOOTHILLS PARKWAY WEST TOWARDS CHILHOWEE RESERVOIR. AT THE DEAD END, TAKE A LEFT ONTO RT 129 AND PROCEED TO GATE AT EXIT OF PARSON BRANCH ROAD. PARK AT GATE AND WALK UP ROAD TO FIRST BRIDGE. SITE BEGINS 40m BELOW BRIDGE.
## 3 DRIVE TO ABRAMS CREEK RANGER STATION. BEFORE RANGER STATION (50 YARDS) TAKE DIRT DRIVE TO THE RIGHT. PROCEED DOWN DRIVE TO STREAM. TAKE TRAIL DOWNSTREAM TO FOOTBRIDGE. SITE BEGINS ~20m BELOW FOOTBRIDGE AND PROCEEDS 200m UPSTREAM. DOWNSTREAM TAG IS O
## 4 DRIVE THROUGH CADES COVE TO PARSONS BRANCH ROAD. PROCEED ON 1-WAY ROAD TO CONFLUENTS OF BIBLE CREEK AND PARSONS BRANCH CREEK. WALK THROU WOODS TO BIBLE CREEK SITE ~ 200m UPSTREAM OF CONFLUENTS WITH PARSONS BRANCH.
## 5 Drive to the Abrams Creek ranger station off of the Foothills parkway west. Proceed upstream to the Abrams Creek campground and take the Cooper Road trail to the Little Bottoms trail. Proceed on Little Bottoms trail, corssing the first major ridge, and
## 6 Drive to Cades Cove and go to back of loop road to Forge Creek Road. Take Forge Creek Road to Parsons Branch Road. Now drive roughly 5 miles on Parsons Branch Road until you cross Hannah Mountain Trail. Drive roughly 0.5 miles past the Hannah Mountain
## COORD_UNIT COORD_SYST DATUM UTM_ZONE MANAGEMENT PARKDISTRI
## 1 dd GCS NAD83 17 <NA> Cades Cove District
## 2 dd GCS NAD83 17 <NA> Cades Cove District
## 3 dd GCS NAD83 17 <NA> Cades Cove District
## 4 dd GCS NAD83 17 <NA> Cades Cove District
## 5 dd GCS NAD83 17 <NA> Cades Cove District
## 6 dd GCS NAD83 17 <NA> Cades Cove District
## CREATEDATE STATION_NA UNITCODE RIVERORDER
## 1 2020-11-14 PAN-5 GRSM 3
## 2 2020-11-14 PAR-1 GRSM 3
## 3 2020-11-14 ABC-1 GRSM 5
## 4 2020-11-14 BIB-1 GRSM 3
## 5 2020-11-14 ABC-1A GRSM 5
## 6 2020-11-14 PAN-10 GRSM 2
## GlobalID VALID_RESU PARK_PROJE SND_PARK_P
## 1 5310abf4-f9d0-4874-9e9e-1d790792d674 Valid General Inventory <NA>
## 2 81b13826-4e3d-46f0-aa8f-204e4c2a84a5 Valid General Inventory <NA>
## 3 08959d94-3d42-427d-bbd0-4ab08ab1a99b Valid IandM <NA>
## 4 d81c90b8-a877-497d-b278-a2fef814a774 Valid General Inventory <NA>
## 5 ddbe08fc-ee5c-4b6a-a4f5-2fa3060a9871 Valid General Inventory <NA>
## 6 4edb3973-cc18-43c6-b96a-a1f16866f708 Valid General Inventory <NA>
## TRD_PARK_P FTH_PARK_P PUBLICDISP DATAACCESS REGIONCODE XYACCURACY
## 1 <NA> <NA> Public Map Display Unrestricted SER Unknown
## 2 <NA> <NA> Public Map Display Unrestricted SER Unknown
## 3 <NA> <NA> Public Map Display Unrestricted SER Unknown
## 4 <NA> <NA> Public Map Display Unrestricted SER Unknown
## 5 <NA> <NA> Public Map Display Unrestricted SER Unknown
## 6 <NA> <NA> Public Map Display Unrestricted SER Unknown
## ZACCURACY MAPMETHOD SITETYPE TAG_UP TAG_DOWN SECTION COMPARE ObjectID
## 1 >=1m and <5m Unknown <NA> NONE NONE 5 TRUE 5603
## 2 >=1m and <5m Unknown <NA> PAR 1U PAR 1D 1 TRUE 5604
## 3 >=1m and <5m Unknown <NA> ABC 1U ABC 1D 1 TRUE 5605
## 4 >=1m and <5m Unknown <NA> BIB 1U BIB 1D 1 TRUE 5606
## 5 >=1m and <5m Unknown <NA> P520 P521 1A TRUE 5607
## 6 >=1m and <5m Unknown <NA> P503 P502 10 TRUE 5608
## PARK_PREF_ ROAD TRAIL geometry
## 1 Panther Creek <NA> <NA> POINT (-83.97437 35.55563)
## 2 Parson Branch <NA> <NA> POINT (-83.92981 35.50098)
## 3 Abrams Creek <NA> <NA> POINT (-83.93448 35.60613)
## 4 Bible Creek <NA> <NA> POINT (-83.92443 35.50677)
## 5 Abrams Creek <NA> <NA> POINT (-83.9141 35.61786)
## 6 Panther Creek <NA> <NA> POINT (-83.90568 35.53871)
#Look up coordinate system
st_crs(ThreePass)
## Coordinate Reference System:
## User input: NAD83
## wkt:
## GEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["latitude",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["longitude",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]]
##NAD83
##Bring in Park Boundary Shapefile from Project Folder
Boundary <- st_read("Boundary\\GRSM_BOUNDARY_POLYGON.shp")
## Reading layer `GRSM_BOUNDARY_POLYGON' from data source
## `C:\R Projects\GRSM Map\GRSM Data\Boundary\GRSM_BOUNDARY_POLYGON.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 27 features and 21 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 226810.1 ymin: 3923747 xmax: 644855.7 ymax: 4158613
## Projected CRS: NAD83 / UTM zone 17N
#Look up coordinate system
st_crs(Boundary)
## Coordinate Reference System:
## User input: NAD83 / UTM zone 17N
## wkt:
## PROJCRS["NAD83 / UTM zone 17N",
## BASEGEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]],
## CONVERSION["UTM zone 17N",
## METHOD["Transverse Mercator",
## ID["EPSG",9807]],
## PARAMETER["Latitude of natural origin",0,
## ANGLEUNIT["Degree",0.0174532925199433],
## ID["EPSG",8801]],
## PARAMETER["Longitude of natural origin",-81,
## ANGLEUNIT["Degree",0.0174532925199433],
## ID["EPSG",8802]],
## PARAMETER["Scale factor at natural origin",0.9996,
## SCALEUNIT["unity",1],
## ID["EPSG",8805]],
## PARAMETER["False easting",500000,
## LENGTHUNIT["metre",1],
## ID["EPSG",8806]],
## PARAMETER["False northing",0,
## LENGTHUNIT["metre",1],
## ID["EPSG",8807]]],
## CS[Cartesian,2],
## AXIS["(E)",east,
## ORDER[1],
## LENGTHUNIT["metre",1]],
## AXIS["(N)",north,
## ORDER[2],
## LENGTHUNIT["metre",1]],
## ID["EPSG",26917]]
##NAD83
#Limit Boundary layer to main Park Boundary
GRSMBoundary <- Boundary[which(Boundary$FID == 17),]
#Transform Main Park Boundary to same Coordinate System as Trails
GRSMBoundary <- st_transform(GRSMBoundary, st_crs(Trails))
##Bring in Trout Distributions (2018) Shapefile from Project Folder
Trout <- st_read("Trout Distribution\\GRSM_FISH_DISTRIBUTION_2018.shp")
## Reading layer `GRSM_FISH_DISTRIBUTION_2018' from data source
## `C:\R Projects\GRSM Map\GRSM Data\Trout Distribution\GRSM_FISH_DISTRIBUTION_2018.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 1013 features and 26 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -83.9903 ymin: 35.44931 xmax: -83.05623 ymax: 35.78421
## Geodetic CRS: NAD83
st_crs(Trout)
## Coordinate Reference System:
## User input: NAD83
## wkt:
## GEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["latitude",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["longitude",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]]
##Bring in Campsite Shapefile from Project Folder
Campsites <- st_read("BC Campsites\\GRSM_BACK_COUNTY_CAMPSITES.shp")
## Reading layer `GRSM_BACK_COUNTY_CAMPSITES' from data source
## `C:\R Projects\GRSM Map\GRSM Data\BC Campsites\GRSM_BACK_COUNTY_CAMPSITES.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 89 features and 74 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -83.92513 ymin: 35.43338 xmax: -83.12218 ymax: 35.7728
## Geodetic CRS: NAD83
st_crs(Campsites)
## Coordinate Reference System:
## User input: NAD83
## wkt:
## GEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["latitude",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["longitude",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]]
##Bring in Tenn Streams Shapefile from Project Folder
#Citation: Tennessee GIS http://tngis.org/water.htm
TennStream <- st_read("TN Streams\\tn_streams.shp")
## Reading layer `tn_streams' from data source
## `C:\R Projects\GRSM Map\GRSM Data\TN Streams\tn_streams.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 163409 features and 21 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -90.30988 ymin: 34.98293 xmax: -81.64813 ymax: 36.67797
## CRS: NA
class(TennStream)
## [1] "sf" "data.frame"
#Define existing coordinate system
TennStream <- st_set_crs(TennStream, 4269)
st_crs(TennStream)
## Coordinate Reference System:
## User input: EPSG:4269
## wkt:
## GEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["geodetic latitude (Lat)",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["geodetic longitude (Lon)",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## USAGE[
## SCOPE["Geodesy."],
## AREA["North America - onshore and offshore: Canada - Alberta; British Columbia; Manitoba; New Brunswick; Newfoundland and Labrador; Northwest Territories; Nova Scotia; Nunavut; Ontario; Prince Edward Island; Quebec; Saskatchewan; Yukon. Puerto Rico. United States (USA) - Alabama; Alaska; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; Hawaii; Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine; Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri; Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York; North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont; Virginia; Washington; West Virginia; Wisconsin; Wyoming. US Virgin Islands. British Virgin Islands."],
## BBOX[14.92,167.65,86.46,-47.74]],
## ID["EPSG",4269]]
#Transform Tennessee Stream data to match coordinate system of Trails data
TennStream <- st_transform(TennStream, st_crs(Trails))
##Bring in NC Streams Shapefile from Project Folder
#Citation: North Carolina Department of Environmental Quality Online GIS https://data-ncdenr.opendata.arcgis.com/datasets/e6b5694f81ed49c6a0f3600540f49878_0?geometry=-85.348%2C34.942%2C-81.175%2C35.726
NCStream <- st_read("NC Streams\\SurfaceWaterClassifications.shp")
## Reading layer `SurfaceWaterClassifications' from data source
## `C:\R Projects\GRSM Map\GRSM Data\NC Streams\SurfaceWaterClassifications.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 12298 features and 10 fields
## Geometry type: MULTILINESTRING
## Dimension: XY
## Bounding box: xmin: 124660.5 ymin: 10464.6 xmax: 930388.2 ymax: 317973.6
## Projected CRS: NAD83 / North Carolina
st_crs(NCStream)
## Coordinate Reference System:
## User input: NAD83 / North Carolina
## wkt:
## PROJCRS["NAD83 / North Carolina",
## BASEGEOGCRS["NAD83",
## DATUM["North American Datum 1983",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## ID["EPSG",4269]],
## CONVERSION["SPCS83 North Carolina zone (meters)",
## METHOD["Lambert Conic Conformal (2SP)",
## ID["EPSG",9802]],
## PARAMETER["Latitude of false origin",33.75,
## ANGLEUNIT["degree",0.0174532925199433],
## ID["EPSG",8821]],
## PARAMETER["Longitude of false origin",-79,
## ANGLEUNIT["degree",0.0174532925199433],
## ID["EPSG",8822]],
## PARAMETER["Latitude of 1st standard parallel",36.1666666666667,
## ANGLEUNIT["degree",0.0174532925199433],
## ID["EPSG",8823]],
## PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,
## ANGLEUNIT["degree",0.0174532925199433],
## ID["EPSG",8824]],
## PARAMETER["Easting at false origin",609601.22,
## LENGTHUNIT["metre",1],
## ID["EPSG",8826]],
## PARAMETER["Northing at false origin",0,
## LENGTHUNIT["metre",1],
## ID["EPSG",8827]]],
## CS[Cartesian,2],
## AXIS["easting (X)",east,
## ORDER[1],
## LENGTHUNIT["metre",1]],
## AXIS["northing (Y)",north,
## ORDER[2],
## LENGTHUNIT["metre",1]],
## USAGE[
## SCOPE["Engineering survey, topographic mapping."],
## AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],
## BBOX[33.83,-84.33,36.59,-75.38]],
## ID["EPSG",32119]]
#Transform North Carolina Stream data to match coordinate system of Trails data
NCStream <- st_transform(NCStream, st_crs(Trails))
Clip shapefiles to only include data within GRSM boundaries
#Ensure the coordinate systems are the same between Trails and GRSMBoundary
st_crs(Trails) == st_crs(GRSMBoundary)
#Subset Trails by Main Park Boundary
GRSMTrails <- Trails[GRSMBoundary,]
#Ensure the coordinate systems are the same between ThreePass and GRSMBoundary
st_crs(ThreePass) == st_crs(GRSMBoundary)
#Subset ThreePass Sites by Main Park Boundary
GRSMThreePass <- ThreePass[GRSMBoundary,]
#"Clip" Tenn Streams by GRSM Boundary
TennStreamGRSM <- st_intersection(TennStream, GRSMBoundary)
#"Clip" NC Streams by GRSM Boundary
NCStreamGRSM <- st_intersection(NCStream, GRSMBoundary)
GRSM staff perform three-pass depletion surveys for trout populations inside of the park. We can use these locations to better inform ideal fishing locations.
This step works to determine which trails are closest to three-pass depletion sites.
#Convert ThreePass and Trails shapefiles into Spatial objects
ThreePassSP <- as(ThreePass, Class = "Spatial")
TrailsSP <- as(Trails, Class = "Spatial")
######################################################
#WARNING: THIS STEP REQUIRES HEAVY COMPUTER USAGE AND#
##MAY TAKE 10+ MINUTES TO COMPLETE #
######################################################
#Use dist2Line function to determine the closest trail to each ThreePass point
#Produces a matrix with distance between point and closest trail
# The lon and lat of the closest part of the trail and the ID of the
# trail segment of the closest trail
DistMatrixDF <- as.data.frame(dist2Line(ThreePassSP, TrailsSP))
#Append an ID field based on row number onto Trails Shapefile
#Used in match() of next step
Trails$MyID <- 1:nrow(Trails)
#Create a No Geometry version of Trails Data
TrailsNoGeom <- Trails
st_geometry(TrailsNoGeom) <- NULL
#Ensure data is in a dataframe
class(TrailsNoGeom)
#Matches the ID of the DistMatrixDF data frame with the Trails ID
#Outputs the Associated TrailName from Trails and appends to DistMatrixDF
DistMatrixDF$TrailName <- TrailsNoGeom[match(DistMatrixDF$ID, TrailsNoGeom$MyID),2]
#Appends Closest Trail Name to each ThreePass point
ThreePass$ClosestTrail <- DistMatrixDF$TrailName
####################################################
#Which Trails have the most ThreePass Access Points#
####################################################
#Create a No Geometry version of ThreePass Data
ThreePassNoGeom <- ThreePass
st_geometry(ThreePassNoGeom) <- NULL
#Create a DF of Trail occurrences in ClosestTrail field of ThreePassNoGeom
TrailCounts <- count(ThreePassNoGeom, ClosestTrail)
#Create meaningful column names
colnames(TrailCounts) <- c("TrailName", "Count")
#Re-order Dataframe in descending occurence order
TrailCounts <- TrailCounts[order(TrailCounts$Count, decreasing = T),]
head(TrailCounts)
###Top Trails for ThreePass Surveys:
#Little Cataloochee Trail (66)
#Palmer Creek Trail (33)
#Anthony Creek Trail (28)
#Goshen Prong Trail (28)
#Middle Prong Trail (21)
#Greenbrier Ridge Trail (16)
#Merge threepass survey counts onto existing trails spatial feature
GRSMTrails <- sp::merge(GRSMTrails, TrailCounts, by.x = "TRAILNAME", by.y = "TrailName", all.x = TRUE)
class(GRSMTrails$Count)
ThreePassTrails <- GRSMTrails[which(GRSMTrails$Count > 15),]
ThreePassTrails
We need to break up the trout data by individual species to better show species’ distributions.
#Split Trout data by species
head(Trout)
RainbowTrout <- Trout[which(Trout$EVENTTYPE == 1 | Trout$EVENTTYPE == 4 | Trout$EVENTTYPE == 5 | Trout$EVENTTYPE == 7),] %>%
mutate(Species = ifelse(EVENTTYPE == "1", "Rainbow",
ifelse(EVENTTYPE == "4", "Rainbow and Brown",
ifelse(EVENTTYPE == "5", "Brook and Rainbow",
ifelse(EVENTTYPE == "7","Brook, Rainbow, and Brown", "No Trout")))))
BrookTrout <- Trout[which(Trout$EVENTTYPE == 2 | Trout$EVENTTYPE == 5 | Trout$EVENTTYPE == 6 | Trout$EVENTTYPE == 7),] %>%
mutate(Species = ifelse(EVENTTYPE == "2", "Brook",
ifelse(EVENTTYPE == "5", "Brook and Rainbow",
ifelse(EVENTTYPE == "6", "Brook and Brown",
ifelse(EVENTTYPE == "7","Brook, Rainbow, and Brown", "No Trout")))))
BrownTrout <- Trout[which(Trout$EVENTTYPE == 4 | Trout$EVENTTYPE == 6 | Trout$EVENTTYPE == 7),] %>%
mutate(Species = ifelse(EVENTTYPE == "4", "Rainbow and Brown",
ifelse(EVENTTYPE == "6", "Brook and Brown",
ifelse(EVENTTYPE == "7", "Brook, Rainbow, and Brown", "No Trout"))))
leaflet() %>% addProviderTiles("Stamen.Terrain", group = "Terrain Map") %>%
addPolygons(data = GRSMBoundary, color = "#404040", fill = FALSE, weight = 6, opacity = .8) %>%
addPolylines(data = GRSMTrails, color = "darkred", weight = 2.5, highlight =
highlightOptions(weight = 7, color = "darkred", bringToFront = TRUE),
popup = paste("Trail Name: ", GRSMTrails$TRAILNAME, ", Intended Use: ", GRSMTrails$DESIGN_USE),
popupOptions = popupOptions(maxWidth =500, closeOnClick = TRUE),
group = "Trails") %>%
addPolylines(data = TennStreamGRSM, weight = 4, color = "#cccccc", popup=
TennStreamGRSM$STREETNAME, popupOptions = popupOptions(maxWidth =500, closeOnClick = TRUE),
group = "Tennessee Streams",
highlight = highlightOptions(weight = 7, color = "#cccccc", bringToFront = TRUE)) %>%
addPolylines(data = NCStreamGRSM, weight = 4, color = "#cccccc", popup =
paste("Parent Stream: ", NCStreamGRSM$Name, NCStreamGRSM$BIMS_Name),
popupOptions = popupOptions(maxWidth =500, closeOnClick = TRUE),
group = "North Carolina Streams",
highlight = highlightOptions(weight = 7, color = "#cccccc", bringToFront = TRUE)) %>%
addPolylines(data = RainbowTrout, weight = 5, color = "#08519c", popup = paste("Trout species present: ",RainbowTrout$Species, ", Stream name: ", RainbowTrout$STREAMNAME), popupOptions =
popupOptions(maxWidth = 500, closeOnClick = TRUE), group = "Rainbow Trout Streams",
highlight = highlightOptions(weight = 8, color = "#08519c", bringToFront = TRUE)) %>%
addPolylines(data = BrookTrout, weight = 5, color = "#4292c6", popup = paste("Trout species present: ",
BrookTrout$Species, ", Stream name: ", BrookTrout$STREAMNAME), popupOptions =
popupOptions(maxWidth = 500, closeOnClick = TRUE), group = "Brook Trout Streams",
highlight = highlightOptions(weight = 8, color = "#4292c6", bringToFront = TRUE)) %>%
addPolylines(data = BrownTrout, weight = 5, color = "#000080", popup = paste("Trout species present: ",
BrownTrout$Species, ", Stream name: ", BrownTrout$STREAMNAME), popupOptions =
popupOptions(maxWidth = 500, closeOnClick = TRUE), group = "Brown Trout Streams",
highlight = highlightOptions(weight = 8, color = "#000080", bringToFront = TRUE)) %>%
addPolylines(data = ThreePassTrails, weight = 3, color = "darkorange", popup =
paste(ThreePassTrails$TRAILNAME, ", ", ThreePassTrails$Count, ", Electroshocking Sites along this trail"),
popupOptions = popupOptions(maxWidth = 500, closeOnClick = TRUE), group = "Top Electroshock Trails",
highlight = highlightOptions(weight = 7,color = "darkorange", bringToFront = TRUE)) %>%
addCircleMarkers(data = Trailheads, radius = 1.5, color = "#CC0000", popup = paste(Trailheads$TRAIL, "off of ", Trailheads$ROAD),
popupOptions = popupOptions(maxWidth = 500, closeOnClick = TRUE), group = "Trail Heads") %>%
addCircleMarkers(data = Campsites, radius = 2, color = "#FF00FF", popup = paste(Campsites$NAME, ", Trail: ",
Campsites$TRAIL, ", Elevation: ", Campsites$ELEV_M), popupOptions =
popupOptions(maxWidth = 500, closeOnClick = TRUE), group = "Backcountry Campsites", clusterOptions = markerClusterOptions()) %>%
addLayersControl(baseGroups = c("Terrain Map", "No Basemap"),
overlayGroups = c("Brook Trout Streams", "Rainbow Trout Streams", "Brown Trout Streams", "Trails", "Top Electroshock Trails",
"Trail Heads", "Backcountry Campsites", "North Carolina Streams", "Tennessee Streams")) %>%
hideGroup(c("Tennessee Streams", "North Carolina Streams", "Trails", "Trail Heads", "Top Electroshock Trails", "Backcountry Campsites")) %>%
addScaleBar(position = c("bottomright"), options = scaleBarOptions(metric = TRUE, maxWidth = 200))
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.