In this exercise we will plot the West-wide site suitability data using simple features and tmap packages.

setwd("C:/Users/Emily Leslie/Documents/PathTo100/")
getwd()
## [1] "C:/Users/Emily Leslie/Documents/PathTo100"
# install sf package if you haven't already
# install.packages("sf")
# load library
library(sf)

# Check working directory to set this up correctly
# Commands  getwd(), my.dir <- getwd(), list.files(my.dir, recursive= TRUE) 
# getwd()
# [1] "C:/Users/Emily Leslie/Documents/earth-analytics/data"

# import data

# To import shapefiles we use the sf library function st_read(). st_read() requires the file path to the shapefile.
ct <- st_read("Data/continent/continent.shp")
## Reading layer `continent' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\continent\continent.shp' using driver `ESRI Shapefile'
## Simple feature collection with 8 features and 5 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -16900910 ymin: -6972041 xmax: 16900900 ymax: 15297990
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
# Reading layer `continent' from data source `C:\Users\Emily Leslie\Documents\earth-analytics\data\continent\continent.shp' using driver `ESRI Shapefile'
# Simple feature collection with 8 features and 5 fields
# geometry type:  MULTIPOLYGON
# dimension:      XY
# bbox:           xmin: -16900910 ymin: -6972041 xmax: 16900900 ymax: 15297990
# epsg (SRID):    NA
# proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs

#install packages and load tmap library if you haven't already 
# install.packages("tmap")
library(tmap)
# Display data
tm_shape(ct) + tm_fill()

# Note the area displayred is too big. 

# Define the area of interest, which can be done by creating a new spatial object, ct_region.
bg_region = st_bbox(c(xmin = -874210.8, xmax = 1051539,
                      ymin = 535177.8, ymax = 2926678),
                    crs = st_crs(ct)) %>% 
  st_as_sfc()

# where did the coordinates for the bounding box come from?  
# we had previously been exploring the "windCF" raster and identified its extent
# get desired spatial extent using bbox()
# load raster library
# library(raster)
# open raster data
# myRas <- raster(x = "week_03/windCF.tif")
# bbox(myRas)
#         min     max
# s1 -874210.8 1051539
# s2  535177.8 2926678

# now that we have created a spatial object representing the extent of the area of interest, we can plot the continent simple feature
ct_map = tm_shape(ct, bbox = bg_region) + tm_fill() 
#set the background color to blue for the ocean
map2 = ct_map + tm_layout(bg.color = "lightblue")


# Add the Western states
# first create a simple feature object "states"
# use st_read function as before
states <- st_read("Data/USAboundaries_aea/USAboundaries_aea.shp")
## Reading layer `USAboundaries_aea' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\USAboundaries_aea\USAboundaries_aea.shp' using driver `ESRI Shapefile'
## Simple feature collection with 51 features and 56 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -4703607 ymin: 456533.4 xmax: 3563081 ymax: 5625473
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
fullWest <- st_read("Data/geogMasks/fullWest.shp")
## Reading layer `fullWest' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\geogMasks\fullWest.shp' using driver `ESRI Shapefile'
## Simple feature collection with 11 features and 57 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -872377.6 ymin: 922080.2 xmax: 1052019 ymax: 2926679
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
# Then add the map object "states" to the map. options are tm_boundary, tm_fill, or others.  
# When using tm_fill(), it will set the fill color to grey by default.
backgroundMap = map2 + tm_shape(states) + tm_fill() + 
  tm_shape(fullWest) + tm_polygons(col = "white")
backgroundMap

In the next section we will add raster layers to the map frame, which currently holds only vector layers. The nice thing about the “tmap” package is that it can handle both vector and raster data layers in the same frame. I had trouble getting “ggplot”" do this.

# New shapes can be added with "+ tm_shape(new_obj)". In this case new_obj represents a new spatial object to be plotted on top of preceding layers. 
# The next code chunk uses the function tm_raster() to plot a raster layer (note we can use alpha set to make the layer semi-transparent):

# First we need to import the solar site suitability polygons
# Previously we had used "st_read" to import a shapefile.  
solarRZCat1 <- st_read("Data/ResourceAssessment/solarCat1RZ.shp")
## Reading layer `solarCat1RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat1RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 28660 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -767710.8 ymin: 1061178 xmax: 859952 ymax: 2134828
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
solarRZCat2 <- st_read("Data/ResourceAssessment/solarCat2RZ.shp")
## Reading layer `solarCat2RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat2RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 22605 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -767710.8 ymin: 1061178 xmax: 859952 ymax: 2134828
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
solarRZCat3 <- st_read("Data/ResourceAssessment/solarCat3RZ.shp")
## Reading layer `solarCat3RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat3RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 9825 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -767210.8 ymin: 1061178 xmax: 859952 ymax: 2134827
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
solarRZCat4 <- st_read("Data/ResourceAssessment/solarCat4RZ.shp")
## Reading layer `solarCat4RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat4RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 5117 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -767210.8 ymin: 1062687 xmax: 852283 ymax: 2134827
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
fullWest <- st_read("Data/geogMasks/fullWest.shp")
## Reading layer `fullWest' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\geogMasks\fullWest.shp' using driver `ESRI Shapefile'
## Simple feature collection with 11 features and 57 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -872377.6 ymin: 922080.2 xmax: 1052019 ymax: 2926679
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
partWestMask <- st_read("Data/geogMasks/partWestMask.shp")
## Reading layer `partWestMask' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\geogMasks\partWestMask.shp' using driver `ESRI Shapefile'
## Simple feature collection with 5 features and 57 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -257148.4 ymin: 1550369 xmax: 1052019 ymax: 2926679
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
inStateMask <- st_read("Data/geogMasks/inStateMask.shp")
## Reading layer `inStateMask' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\geogMasks\inStateMask.shp' using driver `ESRI Shapefile'
## Simple feature collection with 10 features and 57 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -856592.1 ymin: 922080.2 xmax: 1052019 ymax: 2926679
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
# this is a practice map. 
solarOrange = "#f16913"
windBlue = "#4292c6"

inStateSolarCat1RZmap = backgroundMap +
  tm_shape(solarRZCat1) + tm_fill(solarOrange) +
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

Now that we have the basic desired elements plotted together in a frame, let’s repeat the frame in a series of facets

inStateSolarCat1RZmap = backgroundMap +
  tm_shape(solarRZCat1) + tm_fill(solarOrange) +
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

inStateSolarCat2RZmap = backgroundMap +
  tm_shape(solarRZCat2) + tm_fill(solarOrange) +
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

inStateSolarCat3RZmap = backgroundMap +
  tm_shape(solarRZCat3) + tm_fill(solarOrange) +
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

inStateSolarCat4RZmap = backgroundMap +
  tm_shape(solarRZCat4) + tm_fill(solarOrange) +
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

tmap_arrange(inStateSolarCat1RZmap, inStateSolarCat2RZmap, inStateSolarCat3RZmap, inStateSolarCat4RZmap, ncol = 4)

Now that we have categories 1-4 plotted in a series of facets, let’s condense all four categories into a single frame, with shading to represent env category.

# create a color ramp for solar
# install RcolorBrewer package if you haven't already
# install.packages("RColorBrewer")
# use interactive viewer to choose color palette interactive viewer: http://colorbrewer2.org/
library(RColorBrewer)
#create color ramp variable
ramp <- brewer.pal(4, "Oranges")
or1 = ramp[1]
or2 = ramp[2]
or3 = ramp[3]
or4 = ramp[4]


inStateSolarRZmap = backgroundMap +
  tm_shape(solarRZCat1) + tm_fill(or1) +
  tm_shape(solarRZCat2) + tm_fill(or2) +
  tm_shape(solarRZCat3) + tm_fill(or3) + 
  tm_shape(solarRZCat4) + tm_fill(or4) + 
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

inStateSolarRZmap

Ok that looks fine. And it took less than 7 minutes. Now repeat for wind.

# First we need to import the wind site suitability polygons
windRZCat1 <- st_read("Data/ResourceAssessment/windCat1RZ.shp")
## Reading layer `windCat1RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat1RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 6325 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -716960.8 ymin: 1047888 xmax: 883539.2 ymax: 2634678
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
windRZCat2 <- st_read("Data/ResourceAssessment/windCat2RZ.shp")
## Reading layer `windCat2RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat2RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 3969 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -716960.8 ymin: 1047992 xmax: 880646.3 ymax: 2631678
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
windRZCat3 <- st_read("Data/ResourceAssessment/windCat3RZ.shp")
## Reading layer `windCat3RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat3RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1390 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -716960.8 ymin: 1060678 xmax: 869257.9 ymax: 2630336
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
windRZCat4 <- st_read("Data/ResourceAssessment/windCat4RZ.shp")
## Reading layer `windCat4RZ' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat4RZ.shp' using driver `ESRI Shapefile'
## Simple feature collection with 578 features and 9 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -716960.8 ymin: 1060678 xmax: 844068.2 ymax: 2630336
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
#create color ramp for wind
ramp <- brewer.pal(4, "Blues")
bl1 = ramp[1]
bl2 = ramp[2]
bl3 = ramp[3]
bl4 = ramp[4]

# Let's zoom in a bit this time
# Define CA_region
CA_region = st_bbox(c(xmin = -872377.6  , xmax =  -11441.66 ,
                      ymin = 1056313 , ymax = 2155695),
                    crs = st_crs(ct)) %>%
  st_as_sfc()

inStateWindRZmap = backgroundMap +
  tm_shape(windRZCat1) + tm_fill(bl1) +
  tm_shape(windRZCat2) + tm_fill(bl2) +
  tm_shape(windRZCat3) + tm_fill(bl3) + 
  tm_shape(windRZCat4) + tm_fill(bl4) + 
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

inStateWindRZmap

Create map objects for wind and solar Part-West and Full-West scenarios. PLot them all together (6 facets)

partWestSolarRZmap = backgroundMap +
  tm_shape(solarRZCat1) + tm_fill(or1) +
  tm_shape(solarRZCat2) + tm_fill(or2) +
  tm_shape(solarRZCat3) + tm_fill(or3) + 
  tm_shape(solarRZCat4) + tm_fill(or4) + 
  tm_shape(partWestMask) + tm_fill() +
  tm_shape(states, bbox = bg_region) +  tm_borders()

partWestWindRZmap = backgroundMap +
  tm_shape(windRZCat1) + tm_fill(bl1) +
  tm_shape(windRZCat2) + tm_fill(bl2) +
  tm_shape(windRZCat3) + tm_fill(bl3) + 
  tm_shape(windRZCat4) + tm_fill(bl4) + 
  tm_shape(partWestMask) + tm_fill() +
  tm_shape(states, bbox = bg_region) +  tm_borders()

fullWestSolarRZmap = backgroundMap +
  tm_shape(solarRZCat1, bbox = bg_region) + tm_fill(or1) +
  tm_shape(solarRZCat2) + tm_fill(or2) +
  tm_shape(solarRZCat3) + tm_fill(or3) + 
  tm_shape(solarRZCat4) + tm_fill(or4) + 
  tm_shape(states, bbox = bg_region) +  tm_borders()

fullWestWindRZmap = backgroundMap +
  tm_shape(windRZCat1, bbox = bg_region) + tm_fill(or1) +
  tm_shape(windRZCat2) + tm_fill(bl2) +
  tm_shape(windRZCat3) + tm_fill(bl3) + 
  tm_shape(windRZCat4) + tm_fill(bl4) + 
  tm_shape(states, bbox = bg_region) +  tm_borders()

tmap_arrange(inStateSolarRZmap, inStateWindRZmap, partWestSolarRZmap, partWestWindRZmap, fullWestSolarRZmap, fullWestWindRZmap, ncol = 2)

Create map objects for wind and solar wall-to-wall In-state, Part-West and Full-West scenarios. Pot them all together (6 facets)

# First we need to import the wall to wall solar site suitability polygons
solarw2wCat1 <- st_read("Data/ResourceAssessment/solarCat1w2w.shp")
## Reading layer `solarCat1w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat1w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 305666 features and 24 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -866960.8 ymin: 922177.8 xmax: 1051289 ymax: 2926678
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
solarw2wCat2 <- st_read("Data/ResourceAssessment/solarCat2w2w.shp")
## Reading layer `solarCat2w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat2w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 220098 features and 24 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -860703 ymin: 922250.7 xmax: 1051289 ymax: 2926678
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
solarw2wCat3 <- st_read("Data/ResourceAssessment/solarCat3w2w.shp")
## Reading layer `solarCat3w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat3w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 92183 features and 24 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -851710.8 ymin: 922250.7 xmax: 1051289 ymax: 2926678
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
solarw2wCat4 <- st_read("Data/ResourceAssessment/solarCat4w2w.shp")
## Reading layer `solarCat4w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\solarCat4w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 50395 features and 24 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -851710.8 ymin: 922250.7 xmax: 1051289 ymax: 2926624
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
# Import the wall to wall wind site suitability polygons
windw2wCat1 <- st_read("Data/ResourceAssessment/windCat1w2w.shp")
## Reading layer `windCat1w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat1w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 33095 features and 20 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -873210.8 ymin: 927677.8 xmax: 1049781 ymax: 2921400
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
windw2wCat2 <- st_read("Data/ResourceAssessment/windCat2w2w.shp")
## Reading layer `windCat2w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat2w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 18148 features and 20 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -872960.8 ymin: 930177.8 xmax: 1049289 ymax: 2921400
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
windw2wCat3 <- st_read("Data/ResourceAssessment/windCat3w2w.shp")
## Reading layer `windCat3w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat3w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 6207 features and 20 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -869460.8 ymin: 986177.8 xmax: 1020789 ymax: 2921400
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
windw2wCat4 <- st_read("Data/ResourceAssessment/windCat4w2w.shp")
## Reading layer `windCat4w2w' from data source `C:\Users\Emily Leslie\Documents\PathTo100\Data\ResourceAssessment\windCat4w2w.shp' using driver `ESRI Shapefile'
## Simple feature collection with 2549 features and 20 fields
## geometry type:  MULTIPOLYGON
## dimension:      XYZ
## bbox:           xmin: -866912.4 ymin: 986177.8 xmax: 1020789 ymax: 2916178
## epsg (SRID):    NA
## proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-114 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs
inStateSolarW2wmap = backgroundMap +
  tm_shape(solarw2wCat1) + tm_fill(or1) +
  tm_shape(solarw2wCat2) + tm_fill(or2) +
  tm_shape(solarw2wCat3) + tm_fill(or3) + 
  tm_shape(solarw2wCat4) + tm_fill(or4) + 
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

inStateWindW2wMap = backgroundMap +
  tm_shape(windw2wCat1) + tm_fill(bl1) +
  tm_shape(windw2wCat2) + tm_fill(bl2) +
  tm_shape(windw2wCat3) + tm_fill(bl3) + 
  tm_shape(windw2wCat4) + tm_fill(bl4) + 
  tm_shape(inStateMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

partWestSolarW2wMap = backgroundMap +
  tm_shape(solarw2wCat1) + tm_fill(or1) +
  tm_shape(solarw2wCat2) + tm_fill(or2) +
  tm_shape(solarw2wCat3) + tm_fill(or3) + 
  tm_shape(solarw2wCat4) + tm_fill(or4) + 
  tm_shape(partWestMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

partWestWindW2wMap = backgroundMap +
  tm_shape(windw2wCat1) + tm_fill(bl1) +
  tm_shape(windw2wCat2) + tm_fill(bl2) +
  tm_shape(windw2wCat3) + tm_fill(bl3) + 
  tm_shape(windw2wCat4) + tm_fill(bl4) + 
  tm_shape(partWestMask) + tm_fill() +
  tm_shape(states) +  tm_borders()

fullWestSolarW2wMap = backgroundMap +
  tm_shape(solarw2wCat1, bbox = bg_region) + tm_fill(or1) +
  tm_shape(solarw2wCat2) + tm_fill(or2) +
  tm_shape(solarw2wCat3) + tm_fill(or3) + 
  tm_shape(solarw2wCat4) + tm_fill(or4) + 
  tm_shape(states) +  tm_borders()

fullWestWindW2wMap = backgroundMap +
  tm_shape(windw2wCat1, bbox = bg_region) + tm_fill(or1) +
  tm_shape(windw2wCat2) + tm_fill(bl2) +
  tm_shape(windw2wCat3) + tm_fill(bl3) + 
  tm_shape(windw2wCat4) + tm_fill(bl4) + 
  tm_shape(states) +  tm_borders()

tmap_arrange(inStateSolarRZmap, inStateWindRZmap, inStateSolarW2wmap, inStateWindW2wMap, ncol = 4)

#partWestSolarRZmap, partWestWindRZmap, partWestSolarW2wMap, partWestWindW2wMap, fullWestSolarRZmap, fullWestWindRZmap, fullWestSolarW2wMap, fullWestWindW2wMap, ncol = 4)

```