---
# Learning Curve
<img src="lec-img/01-learning-curve.png", width=65%>
--
- If you stick with us, we will get you to the <span class = "code">upswing of awesome</span>
--
- But you must make it through hand holding, confusion, and despair
---
# Why R
So we know we are going to program... but why R?
--
- [R](https://www.r-project.org/) is an object-oriented, functional programming language <span class = "code">specifically designed to interface to other software</spa>.
--
- This is ideal for using libraries written in lower level languages like C, FORTRAN or Java.
--
- Such libraries **will** help you avoid ‘ceiling’ imposed by GUI-based or proprietary geographic information systems.
--
- Furthermore, R facilitates access to other languages: the packages Rcpp and reticulate enable access to C++ and Python code, for example. This means R can be used as a ‘bridge’ to a wide range of existing geospatial **programs**.
<center>
<img src="lec-img/01-osgeo-logo.png", width=35%>
</center>
--
- Learning how to use the wealth of geospatial tools available from the R command line can be exciting, but creating new ones is the key to become a <span class = "code">geospatial scientist rather then a "software user"</span>.
--
- That is, when programming, you are only want to be limited by you, and not the tools you use.
---
# Why r-spatial?
- Strong, dedicated, central, open development community
- `r-spatial` is improving every day and is built on the premise of leveraging external libraries like GDAL, GEOS, and PROJ.
- All of this will become more clear in lecture through out this course
---
# Are we "learning" R?
- <span class = "code">*Yes.*</span> You will learn R and its applications for spatial data science.
--
- <span class = "code">*No.*</span> We are not "teaching" R. Rather, R is one tool for dealing with spatial data. The concepts learned in this course will make you a more efficient analyst in python, ArcMap, Google Earth Engine, ect.
--
- Put another way, learning software is easy, but the concepts here ranging from project structure to analysis will serve you well.
---
# What will we do?
- Build an online presence with a compelling website
--
- Analyze Real-time NY-Times COVID data
--
- Analyze the impacts of real-world policies like the 100-mile DHS border
--
- Analyze the National Dam network and its relationship to water demand
--
- Analyze Satellite Imagery and implement a rudimentary Machine Learning Classification
--
- <span class = "code">You will work at a scale that is meaningful, with real-world messy data, to ask questions that are topical</span>
---
# Instructors
So, who are we?
--
- ### Mike Johnson
- PhD in Geography @ UCSB (July 1st)
- Lead Data Scientist for the Urban Flooding Open Knowledge Network
- Water Resource data scientist for Lynker Technology working @ the NOAA National Water Center
--
<br><br><br>
- ### Jiwon Baik
- PhD Student in Geography @ UCSB
- Operations research / spatial optimization,
- spatial modeling, GIS,
- machine learning and applied statistics.
---
# Mike's Opinions:
To be fair, you should know these things about me:
- I think R is currently the best tool for spatial data science. Others **certainly** disagree.
--
- There are always needs for other tools (GRASS, QGIS, whitebox)
--
- Communicating results is AS IMPORTANT as the results themselves
--
- GIS is a combination of understanding our computers, data science, and geometry.
--
- Everyone can code and everyone will do well in this class if an honest effort is made.
--
- The world is messy, computers are black/white. This is the hardest part of GIS
---
# Our first example:
- Lets practice! Here you are going to see some code.
- <span class = "code">Don't be intimidated by it</span>, but think how it relates to how you understand the world and data you've seen before
- The idea is not to "understand" the code, but to expose the ideas we'll see soon
--
- We start with a data.frame, it might look like something you've seen in excel...
```r
data = data.frame(
name = 'UCSB',
type = 'University',
location = "Goleta, CA",
lat = 34.4140,
lng = -119.8489)
```
<table class="table table-condensed">
<thead>
<tr>
<th style="text-align:right;"> name </th>
<th style="text-align:right;"> type </th>
<th style="text-align:right;"> location </th>
<th style="text-align:right;"> lat </th>
<th style="text-align:right;"> lng </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;"> UCSB </td>
<td style="text-align:right;"> University </td>
<td style="text-align:right;"> Goleta, CA </td>
<td style="text-align:right;"> 34.414 </td>
<td style="text-align:right;"> -119.8489 </td>
</tr>
</tbody>
</table>
---
count: false
# A Simple Map
.panel1-plot-auto[
```r
*ggplot(data)
```
]
.panel2-plot-auto[
<img src="lecture-01_files/figure-html/plot_auto_01_output-1.png" width="432" />
]
---
count: false
# A Simple Map
.panel1-plot-auto[
```r
ggplot(data) +
* geom_point(aes(x = lng, y = lat), size = 4)
```
]
.panel2-plot-auto[
<img src="lecture-01_files/figure-html/plot_auto_02_output-1.png" width="432" />
]
---
count: false
# A Simple Map
.panel1-plot-auto[
```r
ggplot(data) +
geom_point(aes(x = lng, y = lat), size = 4) +
* labs(title = "UCSB Location ")
```
]
.panel2-plot-auto[
<img src="lecture-01_files/figure-html/plot_auto_03_output-1.png" width="432" />
]
---
count: false
# A Simple Map
.panel1-plot-auto[
```r
ggplot(data) +
geom_point(aes(x = lng, y = lat), size = 4) +
labs(title = "UCSB Location ") +
* theme_bw()
```
]
.panel2-plot-auto[
<img src="lecture-01_files/figure-html/plot_auto_04_output-1.png" width="432" />
]
<style>
.panel1-plot-auto {
color: black;
width: 38.6060606060606%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel2-plot-auto {
color: black;
width: 59.3939393939394%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel3-plot-auto {
color: black;
width: NA%;
hight: 33%;
float: left;
padding-left: 1%;
font-size: 80%
}
</style>
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
*library(dplyr)
```
]
.panel2-spatial-auto[
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
*library(osmdata)
```
]
.panel2-spatial-auto[
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
library(osmdata)
*(AOI = AOI::aoi_get(list(data$lat, data$lng, .5,.5)))
```
]
.panel2-spatial-auto[
```
Simple feature collection with 1 feature and 0 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8533 ymin: 34.41038 xmax: -119.8445 ymax: 34.41762
Geodetic CRS: WGS 84
sf..st_as_sfc.x.
1 POLYGON ((-119.8533 34.4103...
```
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
library(osmdata)
(AOI = AOI::aoi_get(list(data$lat, data$lng, .5,.5)))
*(osm_data = opq(AOI) %>%
* add_osm_feature (key = "building") %>%
* osmdata_sf())
```
]
.panel2-spatial-auto[
```
Simple feature collection with 1 feature and 0 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8533 ymin: 34.41038 xmax: -119.8445 ymax: 34.41762
Geodetic CRS: WGS 84
sf..st_as_sfc.x.
1 POLYGON ((-119.8533 34.4103...
```
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
library(osmdata)
(AOI = AOI::aoi_get(list(data$lat, data$lng, .5,.5)))
(osm_data = opq(AOI) %>%
add_osm_feature (key = "building") %>%
osmdata_sf())
*osm_data$osm_polygons
```
]
.panel2-spatial-auto[
```
Simple feature collection with 1 feature and 0 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8533 ymin: 34.41038 xmax: -119.8445 ymax: 34.41762
Geodetic CRS: WGS 84
sf..st_as_sfc.x.
1 POLYGON ((-119.8533 34.4103...
```
```
Simple feature collection with 81 features and 37 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8532 ymin: 34.40987 xmax: -119.8438 ymax: 34.41799
Geodetic CRS: WGS 84
First 10 features:
osm_id name addr.housename addr.state alt_name amenity bench bldg_no building building.levels buildingty capacity
38097306 38097306 El Centro <NA> <NA> <NA> <NA> <NA> <NA> yes <NA> <NA> <NA>
38099471 38099471 College of Creative Studies <NA> <NA> <NA> <NA> <NA> <NA> university <NA> <NA> <NA>
38140509 38140509 Lot 18/Mesa <NA> <NA> <NA> parking <NA> <NA> yes <NA> <NA> 907
43080366 43080366 UCSB Bike Shop <NA> CA <NA> <NA> <NA> <NA> school <NA> <NA> <NA>
43939827 43939827 <NA> <NA> <NA> <NA> toilets <NA> <NA> yes <NA> <NA> <NA>
49425354 49425354 Lot 22 <NA> <NA> <NA> parking <NA> <NA> yes <NA> <NA> 1128
221234145 221234145 Psychology <NA> <NA> <NA> <NA> <NA> <NA> university <NA> <NA> <NA>
221234146 221234146 Psychology Addition <NA> <NA> <NA> <NA> <NA> <NA> university <NA> <NA> <NA>
221234147 221234147 Psychology <NA> <NA> <NA> <NA> <NA> <NA> university <NA> <NA> <NA>
221234879 221234879 Ortega Dining Commons <NA> <NA> <NA> food_court <NA> <NA> yes <NA> <NA> <NA>
capacity.disabled disabled_spaces ele fee gnis.county_name gnis.feature_id gnis.import_uuid gnis.reviewed height layer leisure
38097306 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
38099471 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
38140509 yes <NA> <NA> yes <NA> <NA> <NA> <NA> <NA> <NA> <NA>
43080366 <NA> <NA> 14 <NA> Santa Barbara 1665582 57871b70-0100-4405-bb30-88b2e001a944 no <NA> <NA> <NA>
43939827 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
49425354 <NA> yes <NA> yes <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234145 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234146 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234147 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234879 <NA> <NA> 14 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
operator parking phone ref seats shelter_type shop short_name source tourism website wheelchair wikidata wikipedia
38097306 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
38099471 <NA> <NA> <NA> 494 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
38140509 <NA> multi-storey <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
43080366 Associated Students <NA> <NA> <NA> <NA> <NA> bicycle <NA> USGS Geonames <NA> <NA> <NA> <NA> <NA>
43939827 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
49425354 <NA> multi-storey <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234145 <NA> <NA> <NA> 551 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234146 <NA> <NA> <NA> 251 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234147 <NA> <NA> <NA> 551 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
221234879 <NA> <NA> <NA> 542 <NA> <NA> <NA> <NA> <NA> <NA> <NA> yes <NA> <NA>
geometry
38097306 POLYGON ((-119.8445 34.4143...
38099471 POLYGON ((-119.8461 34.4113...
38140509 POLYGON ((-119.8471 34.4174...
43080366 POLYGON ((-119.8493 34.4145...
43939827 POLYGON ((-119.8529 34.4177...
49425354 POLYGON ((-119.853 34.41383...
221234145 POLYGON ((-119.8448 34.4120...
221234146 POLYGON ((-119.8445 34.4122...
221234147 POLYGON ((-119.8448 34.4123...
221234879 POLYGON ((-119.8472 34.4112...
```
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
library(osmdata)
(AOI = AOI::aoi_get(list(data$lat, data$lng, .5,.5)))
(osm_data = opq(AOI) %>%
add_osm_feature (key = "building") %>%
osmdata_sf())
osm_data$osm_polygons %>%
* select(name)
```
]
.panel2-spatial-auto[
```
Simple feature collection with 1 feature and 0 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8533 ymin: 34.41038 xmax: -119.8445 ymax: 34.41762
Geodetic CRS: WGS 84
sf..st_as_sfc.x.
1 POLYGON ((-119.8533 34.4103...
```
```
Simple feature collection with 81 features and 1 field
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8532 ymin: 34.40987 xmax: -119.8438 ymax: 34.41799
Geodetic CRS: WGS 84
First 10 features:
name geometry
38097306 El Centro POLYGON ((-119.8445 34.4143...
38099471 College of Creative Studies POLYGON ((-119.8461 34.4113...
38140509 Lot 18/Mesa POLYGON ((-119.8471 34.4174...
43080366 UCSB Bike Shop POLYGON ((-119.8493 34.4145...
43939827 <NA> POLYGON ((-119.8529 34.4177...
49425354 Lot 22 POLYGON ((-119.853 34.41383...
221234145 Psychology POLYGON ((-119.8448 34.4120...
221234146 Psychology Addition POLYGON ((-119.8445 34.4122...
221234147 Psychology POLYGON ((-119.8448 34.4123...
221234879 Ortega Dining Commons POLYGON ((-119.8472 34.4112...
```
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
library(osmdata)
(AOI = AOI::aoi_get(list(data$lat, data$lng, .5,.5)))
(osm_data = opq(AOI) %>%
add_osm_feature (key = "building") %>%
osmdata_sf())
osm_data$osm_polygons %>%
select(name) %>%
* mutate(area = sf::st_area(.))
```
]
.panel2-spatial-auto[
```
Simple feature collection with 1 feature and 0 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8533 ymin: 34.41038 xmax: -119.8445 ymax: 34.41762
Geodetic CRS: WGS 84
sf..st_as_sfc.x.
1 POLYGON ((-119.8533 34.4103...
```
```
Simple feature collection with 81 features and 2 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8532 ymin: 34.40987 xmax: -119.8438 ymax: 34.41799
Geodetic CRS: WGS 84
First 10 features:
name geometry area
38097306 El Centro POLYGON ((-119.8445 34.4143... 458.2097 [m^2]
38099471 College of Creative Studies POLYGON ((-119.8461 34.4113... 1596.2803 [m^2]
38140509 Lot 18/Mesa POLYGON ((-119.8471 34.4174... 8739.1584 [m^2]
43080366 UCSB Bike Shop POLYGON ((-119.8493 34.4145... 129.5989 [m^2]
43939827 <NA> POLYGON ((-119.8529 34.4177... 120.9094 [m^2]
49425354 Lot 22 POLYGON ((-119.853 34.41383... 5484.2148 [m^2]
221234145 Psychology POLYGON ((-119.8448 34.4120... 1730.7990 [m^2]
221234146 Psychology Addition POLYGON ((-119.8445 34.4122... 821.4632 [m^2]
221234147 Psychology POLYGON ((-119.8448 34.4123... 728.1013 [m^2]
221234879 Ortega Dining Commons POLYGON ((-119.8472 34.4112... 2565.3212 [m^2]
```
]
---
count: false
# Finding Data
.panel1-spatial-auto[
```r
library(dplyr)
library(osmdata)
(AOI = AOI::aoi_get(list(data$lat, data$lng, .5,.5)))
(osm_data = opq(AOI) %>%
add_osm_feature (key = "building") %>%
osmdata_sf())
osm_data$osm_polygons %>%
select(name) %>%
mutate(area = sf::st_area(.)) ->
* buildings
```
]
.panel2-spatial-auto[
```
Simple feature collection with 1 feature and 0 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8533 ymin: 34.41038 xmax: -119.8445 ymax: 34.41762
Geodetic CRS: WGS 84
sf..st_as_sfc.x.
1 POLYGON ((-119.8533 34.4103...
```
]
<style>
.panel1-spatial-auto {
color: black;
width: 38.6060606060606%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel2-spatial-auto {
color: black;
width: 59.3939393939394%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel3-spatial-auto {
color: black;
width: NA%;
hight: 33%;
float: left;
padding-left: 1%;
font-size: 80%
}
</style>
---
count: false
# A more informative map
.panel1-spatial-plot-auto[
```r
*ggplot(buildings)
```
]
.panel2-spatial-plot-auto[
<img src="lecture-01_files/figure-html/spatial-plot_auto_01_output-1.png" width="432" />
]
---
count: false
# A more informative map
.panel1-spatial-plot-auto[
```r
ggplot(buildings) +
* geom_sf()
```
]
.panel2-spatial-plot-auto[
<img src="lecture-01_files/figure-html/spatial-plot_auto_02_output-1.png" width="432" />
]
---
count: false
# A more informative map
.panel1-spatial-plot-auto[
```r
ggplot(buildings) +
geom_sf() +
* geom_sf(data = slice_max(buildings, area), fill = "red")
```
]
.panel2-spatial-plot-auto[
<img src="lecture-01_files/figure-html/spatial-plot_auto_03_output-1.png" width="432" />
]
---
count: false
# A more informative map
.panel1-spatial-plot-auto[
```r
ggplot(buildings) +
geom_sf() +
geom_sf(data = slice_max(buildings, area), fill = "red") +
* geom_sf(data = filter(buildings, name == "Ellison Hall"), fill = "green")
```
]
.panel2-spatial-plot-auto[
<img src="lecture-01_files/figure-html/spatial-plot_auto_04_output-1.png" width="432" />
]
---
count: false
# A more informative map
.panel1-spatial-plot-auto[
```r
ggplot(buildings) +
geom_sf() +
geom_sf(data = slice_max(buildings, area), fill = "red") +
geom_sf(data = filter(buildings, name == "Ellison Hall"), fill = "green") +
* labs(title = "UCSB Campus",
* subtitle = "Green builing is Ellison Hall")
```
]
.panel2-spatial-plot-auto[
<img src="lecture-01_files/figure-html/spatial-plot_auto_05_output-1.png" width="432" />
]
---
count: false
# A more informative map
.panel1-spatial-plot-auto[
```r
ggplot(buildings) +
geom_sf() +
geom_sf(data = slice_max(buildings, area), fill = "red") +
geom_sf(data = filter(buildings, name == "Ellison Hall"), fill = "green") +
labs(title = "UCSB Campus",
subtitle = "Green builing is Ellison Hall") +
* theme_bw()
```
]
.panel2-spatial-plot-auto[
<img src="lecture-01_files/figure-html/spatial-plot_auto_06_output-1.png" width="432" />
]
<style>
.panel1-spatial-plot-auto {
color: black;
width: 38.6060606060606%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel2-spatial-plot-auto {
color: black;
width: 59.3939393939394%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel3-spatial-plot-auto {
color: black;
width: NA%;
hight: 33%;
float: left;
padding-left: 1%;
font-size: 80%
}
</style>
---
# Analysis
**Question**: What is the solar potential of the 25 largest buildings on UCSB's campus?
.pull-left[
<img src="lec-img/01-national-solar-map.png", width=80%>
]
.pull-right[
Assumptions:
- 75% of a structure footprint can be covered with solar panel
- Goleta gets ~5 kWh/m^2^/day
- 1 kWhr = .000000010 gWhr
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
*buildings
```
]
.panel2-solar-auto[
```
Simple feature collection with 81 features and 2 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8532 ymin: 34.40987 xmax: -119.8438 ymax: 34.41799
Geodetic CRS: WGS 84
First 10 features:
name geometry area
38097306 El Centro POLYGON ((-119.8445 34.4143... 458.2097 [m^2]
38099471 College of Creative Studies POLYGON ((-119.8461 34.4113... 1596.2803 [m^2]
38140509 Lot 18/Mesa POLYGON ((-119.8471 34.4174... 8739.1584 [m^2]
43080366 UCSB Bike Shop POLYGON ((-119.8493 34.4145... 129.5989 [m^2]
43939827 <NA> POLYGON ((-119.8529 34.4177... 120.9094 [m^2]
49425354 Lot 22 POLYGON ((-119.853 34.41383... 5484.2148 [m^2]
221234145 Psychology POLYGON ((-119.8448 34.4120... 1730.7990 [m^2]
221234146 Psychology Addition POLYGON ((-119.8445 34.4122... 821.4632 [m^2]
221234147 Psychology POLYGON ((-119.8448 34.4123... 728.1013 [m^2]
221234879 Ortega Dining Commons POLYGON ((-119.8472 34.4112... 2565.3212 [m^2]
```
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
* slice_max(area, n = 25)
```
]
.panel2-solar-auto[
```
Simple feature collection with 25 features and 2 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8532 ymin: 34.41004 xmax: -119.8438 ymax: 34.41799
Geodetic CRS: WGS 84
First 10 features:
name area geometry
355809608 Davidson Library 11215.993 [m^2] POLYGON ((-119.8453 34.4143...
38140509 Lot 18/Mesa 8739.158 [m^2] POLYGON ((-119.8471 34.4174...
221241134 <NA> 8411.759 [m^2] POLYGON ((-119.844 34.41641...
221404493 <NA> 7495.132 [m^2] POLYGON ((-119.8467 34.4126...
221239778 Rob Gym 6469.864 [m^2] POLYGON ((-119.8498 34.4164...
221234882 University Center (UCEN) 5987.472 [m^2] POLYGON ((-119.8472 34.4117...
221237576 Humanities and Social Sciences 5841.466 [m^2] POLYGON ((-119.8499 34.4133...
221409402 Santa Rosa Hall 5812.156 [m^2] POLYGON ((-119.8447 34.4113...
49425354 Lot 22 5484.215 [m^2] POLYGON ((-119.853 34.41383...
221240083 <NA> 4424.639 [m^2] POLYGON ((-119.8526 34.4156...
```
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
* mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010)
```
]
.panel2-solar-auto[
```
Simple feature collection with 25 features and 3 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -119.8532 ymin: 34.41004 xmax: -119.8438 ymax: 34.41799
Geodetic CRS: WGS 84
First 10 features:
name area geometry gWhr
355809608 Davidson Library 11215.993 [m^2] POLYGON ((-119.8453 34.4143... 0.04205997
38140509 Lot 18/Mesa 8739.158 [m^2] POLYGON ((-119.8471 34.4174... 0.03277184
221241134 <NA> 8411.759 [m^2] POLYGON ((-119.844 34.41641... 0.03154410
221404493 <NA> 7495.132 [m^2] POLYGON ((-119.8467 34.4126... 0.02810675
221239778 Rob Gym 6469.864 [m^2] POLYGON ((-119.8498 34.4164... 0.02426199
221234882 University Center (UCEN) 5987.472 [m^2] POLYGON ((-119.8472 34.4117... 0.02245302
221237576 Humanities and Social Sciences 5841.466 [m^2] POLYGON ((-119.8499 34.4133... 0.02190550
221409402 Santa Rosa Hall 5812.156 [m^2] POLYGON ((-119.8447 34.4113... 0.02179559
49425354 Lot 22 5484.215 [m^2] POLYGON ((-119.853 34.41383... 0.02056581
221240083 <NA> 4424.639 [m^2] POLYGON ((-119.8526 34.4156... 0.01659239
```
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
* solar_options
```
]
.panel2-solar-auto[
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
solar_options
*ggplot()
```
]
.panel2-solar-auto[
<img src="lecture-01_files/figure-html/solar_auto_05_output-1.png" width="432" />
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
solar_options
ggplot() +
* geom_sf(data = buildings, fill = 'gray')
```
]
.panel2-solar-auto[
<img src="lecture-01_files/figure-html/solar_auto_06_output-1.png" width="432" />
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
solar_options
ggplot() +
geom_sf(data = buildings, fill = 'gray') +
* geom_sf(data = solar_options, aes(fill = gWhr))
```
]
.panel2-solar-auto[
<img src="lecture-01_files/figure-html/solar_auto_07_output-1.png" width="432" />
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
solar_options
ggplot() +
geom_sf(data = buildings, fill = 'gray') +
geom_sf(data = solar_options, aes(fill = gWhr)) +
* scale_fill_gradientn(colors = pals::parula(10))
```
]
.panel2-solar-auto[
<img src="lecture-01_files/figure-html/solar_auto_08_output-1.png" width="432" />
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
solar_options
ggplot() +
geom_sf(data = buildings, fill = 'gray') +
geom_sf(data = solar_options, aes(fill = gWhr)) +
scale_fill_gradientn(colors = pals::parula(10)) +
* labs(title = "UCSB Solor Options")
```
]
.panel2-solar-auto[
<img src="lecture-01_files/figure-html/solar_auto_09_output-1.png" width="432" />
]
---
count: false
# UCSB Solar
.panel1-solar-auto[
```r
buildings %>%
slice_max(area, n = 25) %>%
mutate(gWhr = 0.75 * as.numeric(area) * 5 * 0.0000010) ->
solar_options
ggplot() +
geom_sf(data = buildings, fill = 'gray') +
geom_sf(data = solar_options, aes(fill = gWhr)) +
scale_fill_gradientn(colors = pals::parula(10)) +
labs(title = "UCSB Solor Options") +
* theme_bw()
```
]
.panel2-solar-auto[
<img src="lecture-01_files/figure-html/solar_auto_10_output-1.png" width="432" />
]
<style>
.panel1-solar-auto {
color: black;
width: 38.6060606060606%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel2-solar-auto {
color: black;
width: 59.3939393939394%;
hight: 32%;
float: left;
padding-left: 1%;
font-size: 80%
}
.panel3-solar-auto {
color: black;
width: NA%;
hight: 33%;
float: left;
padding-left: 1%;
font-size: 80%
}
</style>
---
# UCSB 2018 Annual Utility and Energy Report
See [here](https://www.energy.ucsb.edu/sites/default/files/docs/UCSB_Annual_Energy_Utility_Report_2018.pdf)
.pull-left[
<img src="lec-img/01-ucsb-solar-costs.png", width=50%>
]
--
.pull-right[
```r
sum(solar_options$gWh)
```
```
[1] 0.4319673
```
]
---
class: center, middle
# Assignment: [Set up R and Rstudio](01-assignment.html)
---
class: center, middle
# END
<style type="text/css">
.remark-code{line-height: 1.5; font-size: 65%}
</style>