Thurston County Wetlands

Harold Nelson

11/9/2021

Setup

library(tidyverse)
library(sf)
library(tmap)

There is a video walkthrough available at https://www.youtube.com/watch?v=eIBv5wkoUTc.

Right-click and select open in new tab/window to watch.

Thurston County Geodata

I went to the Thurston County GeoData Center at https://gisdata-thurston.opendata.arcgis.com/search?source=thurston%20geodata%20center&tags=Health&type=feature%20layer

I decided to look at the wetlands data and selected the geojson version.

wl = st_read("Thurston_Wetlands.geojson")
## Reading layer `Thurston_Wetlands' from data source 
##   `/Users/haroldnelson/Dropbox/WA Geodata/Thurston_Wetlands.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 10037 features and 10 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -123.1986 ymin: 46.76264 xmax: -122.2018 ymax: 47.17407
## Geodetic CRS:  WGS 84
tmap_options(check.and.fix = TRUE)
tm_shape(wl) + tm_polygons()
## Warning: The shape wl is invalid. See sf::st_is_valid

Wetland Codes

Look at the data in this file.

str(wl)
## Classes 'sf' and 'data.frame':   10037 obs. of  11 variables:
##  $ OBJECTID                : int  299941 299942 299943 299944 299945 299946 299947 299948 299949 299950 ...
##  $ NWI_Code                : chr  "PEMf" "PEM/SS" "PFO/SS" "R2US" ...
##  $ PrimaryWetlandSystemCode: chr  "P" "P" " " " " ...
##  $ ClassCode1              : chr  "EM" "EM" " " " " ...
##  $ ClassCode2              : chr  " " "SS" " " " " ...
##  $ Modifier                : chr  "f" " " " " " " ...
##  $ WetlandType             : chr  "WET" "WET" "WET" "WET" ...
##  $ CREATE_DATE             : POSIXct, format: "2017-10-31 04:54:51" "2017-10-31 04:54:51" ...
##  $ EDIT_DATE               : POSIXct, format: "2017-10-31 04:54:51" "2017-10-31 04:54:51" ...
##  $ GlobalID                : chr  "{008224D7-B774-4F3A-997D-202835366F13}" "{0124DE62-2011-4F5F-8099-79DC1E68F5C2}" "{0159A8CF-5D2F-4CDA-A85B-276DAAE4E074}" "{019A3B64-5311-4C55-880D-3FAB1F1F313D}" ...
##  $ geometry                :sfc_MULTIPOLYGON of length 10037; first list element: List of 1
##   ..$ :List of 1
##   .. ..$ : num [1:92, 1:2] -123 -123 -123 -123 -123 ...
##   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA
##   ..- attr(*, "names")= chr [1:10] "OBJECTID" "NWI_Code" "PrimaryWetlandSystemCode" "ClassCode1" ...

NWI_Code

Look at the values of NWI_code.

table(wl$NWI_Code)
## 
##      E2AB   E2AB/US      E2EM   E2EM/UB   E2EM/US        L1      L1OW     L1OWh 
##         3         1        53         4         2         1        22         1 
##      L1UB     L1UBH    L1UBHH      L2AB   L2AB/OW      L2OW   L2OW/AB    L2USAH 
##         2         2         3        10         3        18         5         1 
##    L2USCH       PAB    PAB/EM    PAB/OW    PAB/SS  PAB4/OWZ     PAB4Z      PABH 
##         2        22         6         8         1         1         1         3 
##      PABx       PEM    PEM/AB   PEM/ABH   PEM/EMf    PEM/FO   PEM/FOf    PEM/ML 
##         1      1002        19         1         1        20         7         1 
##    PEM/OW   PEM/OWf   PEM/OWx    PEM/SS  PEM/SSag   PEM/SSf  PEM1/OWY  PEM1/OWZ 
##        59        70         3       170         3        31         9         1 
##     PEM1W     PEM1Y      PEMA     PEMag PEMag/EMf      PEMC     PEMCB     PEMCh 
##         7        33         6         4         1       111         4        35 
##     PEMCH     PEMCX      PEMf      PEMF     PEMFB     PEMfd     PEMfh     PEMFH 
##         5         6       990         5         7        13         5         3 
##      PEMx    PFLKYX       PFO    PFO/EM   PFO/EMf    PFO/OW    PFO/SS  PFO/SSag 
##         2         1      2431        21        12        17       151         8 
##   PFO/SSf     PFO1W     PFO1Y PFO5/OWZH      PFOA     PFOag      PFOB      PFOC 
##         2         3         2         2        17        33         1        40 
##     PFOCB      PFOf  PML/ABag     PMLag       POW    POW/AB    POW/EM  POW/EMag 
##         1         3         1         1       749        46        64         1 
##   POW/EMf   POW/EMx    POW/FO    POW/SS   POW/SSx     POWag      POWf      POWh 
##        27         3        14        32         3         1         7         3 
##     POWKZ      POWx      POWY      POWZ     POWZH       PSS    PSS/AB    PSS/EM 
##         1       230         1        13         1      1422         1       127 
##  PSS/EM1W   PSS/EMf    PSS/FO  PSS/FOag   PSS/FOC    PSS/OW   PSS/OWf     PSS1W 
##         1        17       188         6         1        23         1         4 
##     PSS1Y      PSSA     PSSag      PSSC     PSSCB     PSSCH      PSSd      PSSf 
##        17         4        46       147        13         8         1        21 
##       PUB    PUB/EM     PUBFX      PUBH     PUBHH     PUBHX      PUBx       PUS 
##         4         2         3         2         4         3         2        22 
##    PUS/SS     PUSCX        R1      R1US        R2      R2US        R3      R3OW 
##         3         4        11         1        40        75        84         1 
##      R3UB     R3UBH      R3US     R3USA     R3USC        R4       XXX 
##         1        14        67         2        46       733         3

I followed up and found that the first letter “R” indicates a “Riverine” Wetland.

See https://fwsprimary.wim.usgs.gov/decoders/wetlands.aspx

Riverine Wetlands

wlr = wl %>% filter(substr(NWI_Code,1,1) == "R")
tm_shape(wlr) + tm_polygons(lwd=2)
## Warning: The shape wlr is invalid. See sf::st_is_valid

Border of Thurston County

I threw in the border of Thurston County from https://gisdata-thurston.opendata.arcgis.com/datasets/thurston-county-border/explore?location=47.011928%2C-122.674563%2C10.18

I used the kml version in this case.

thb = st_read("Thurston_County_Border.kml")
## Reading layer `Thurston_County_Border' from data source 
##   `/Users/haroldnelson/Dropbox/WA Geodata/Thurston_County_Border.kml' 
##   using driver `KML'
## Simple feature collection with 7 features and 2 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -123.2031 ymin: 46.76205 xmax: -122.2154 ymax: 47.18682
## Geodetic CRS:  WGS 84
tm_shape(thb) + 
  tm_borders(col= "red",lwd=3) +
tm_shape(wlr) + tm_borders(col= "blue",lwd=2)  
## Warning: The shape wlr is invalid. See sf::st_is_valid