class: center, middle, inverse, title-slide # Geography 13 ## Lecture 02: Class Roadmap ### Mike Johnson --- <style type="text/css"> .remark-code{font-size: 100%} </style> <center> <img src="lec-img/02-road-map.jpg" width="50%"> </center> -- - Today is a broad overview of the content we will cover in class -- - The goal is to show you now how all the pieces we will learn fit together -- - Again, the code is meant for us just to get comfortable seeing code and listening to it be talked about. --- # Key points today are: -- - tables -- - geometries -- - binary/boolean conditions (TRUE/FALSE) -- - data dimensions (1D, 2D, 3D, 4D) --- ## Whats in a name? <center> <img src="lec-img/02-gis-layers.jpg"> </center> --- class: center, middle <center> <img src="lec-img/02-gis-eras.jpg"> </center> -- ### largely this is how 176 has been taught at UCSB... technology --> concepts --> applications --- .pull-left[ ### Information _Systems_: - **Information Systems**: complementary networks of hardware and software used to <span class="code">collect, filter, process, create and distribute data</span>. - **Geographic Information Systems**: a framework that provides the ability to capture and <span class="code">analyze spatial and geographic data</span>. ] .pull-right[ <center> <img src="lec-img/02-information-systems.png" width = "75%"> </center> ] --- ## ... .pull-left[ ### Information _Science_: - **Information Science**: the study of _storing_ and _retrieving_ information. - **Geographic Information Science**: studies the techniques to capture, represent, process, and analyze geographic information. ] .pull-right[ <center> <img src="lec-img/02-info-science.png" width = "75%"> </center> ] --- ## ... ### Data Science - **Data Science**: the discovery and communication of knowledge, patterns, or actionable information in <span class="code">structured</span> and unstructured data. - **Data Models**: abstract (general) model that organizes elements of data and standardizes how they relate to one another and to the properties of real-world entities. A data model can sometimes be referred to as a <span class="code">data structure</span>, especially in the context of programming languages. <center> <img src="lec-img/02-data-science.png" width = "75%"> </center> --- # So... - Data Models tell us _what_ should be stored in an element of data and how it is organized <br><br>
<br> - Information Science tells us _how_ to store and retrieve many elements <br><br>
<br> - Data Science informs how we _anaylsize_ and _evaluate_ collections of elements <br><br> sum(
) = 3 - Systems have been built to support these missions --- class: center, middle *Geoinformatics* is the science and the technology which develops and uses **information science** infrastructure to address the problems of geography, cartography, geosciences. -- _How do we combine the knowledge of <u>computer science</u>, <u>mathmatics</u>, <u>information science</u>, and <u>data science</u> to answer geographic questions?_ -- To answer this I suggest that we need to address **3** 1. understand our computer and systems for working with digital data in a reproducible, flexable way. 2. Have a strong foundation in standard data manipulation and data visualization 3. Understand what makes "spatial" special including familiarity with dealing with vector objects, raster fields, and time. --- ## Introduction to Geoinformatics 1. You will build habits that will allow your work to be reproducible and shared (**week 1**) - R, Github, Markdown (our computer) 2. You will learn to analyze, clean, and communicate structured data in a open-source coding environment (**week 2**) - Data wrangling - Data Visualization 3. You will learn the underlying data models of spatial data (**week 3-6**) - Raster and Vector Data Models and Operations --- ## Structured Data - Generally pre-defined data models - Usually resides in relational databases ([RDBMS](https://techterms.com/definition/rdbms#:~:text=Terms%20%3A%20RDBMS%20Definition-,RDBMS,format%2C%20using%20rows%20and%20columns.)). - Fields store data of a same type (character, boolean, double, factor). - Data may be human - or machine - generated as long as the data is created within an a known structure. -- ## Unstructured Data - **Unstructured** data either does not have a defined data model or is not organized in a pre-defined manner. - typically text-heavy (think Social Media, Webpages, emails), but may contain data such as dates, numbers, and facts. - results in ambiguities that require advanced techniques such as semantic tagging or natural language processing (NLP) --- <img src="lec-img/02-structuredVsUnstructured.png" width="711" /> --- ## Data science: the table view - structured - rows, columns, - ["tidy" data](https://vita.had.co.nz/papers/tidy-data.pdf) is ideal (rows = observations; columns = variables/attributes) --- # A typical approach ... ```r url <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2018/2018-11-06/us_wind.csv" us_wind <- readr::read_csv(url) %>% select(t_state, t_county, xlong, ylat) skimr::skim(us_wind) ``` <table style='width: auto;' class='table table-condensed'> <caption>Data summary</caption> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:left;"> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Name </td> <td style="text-align:left;"> us_wind </td> </tr> <tr> <td style="text-align:left;"> Number of rows </td> <td style="text-align:left;"> 58185 </td> </tr> <tr> <td style="text-align:left;"> Number of columns </td> <td style="text-align:left;"> 4 </td> </tr> <tr> <td style="text-align:left;"> _______________________ </td> <td style="text-align:left;"> </td> </tr> <tr> <td style="text-align:left;"> Column type frequency: </td> <td style="text-align:left;"> </td> </tr> <tr> <td style="text-align:left;"> character </td> <td style="text-align:left;"> 2 </td> </tr> <tr> <td style="text-align:left;"> numeric </td> <td style="text-align:left;"> 2 </td> </tr> <tr> <td style="text-align:left;"> ________________________ </td> <td style="text-align:left;"> </td> </tr> <tr> <td style="text-align:left;"> Group variables </td> <td style="text-align:left;"> None </td> </tr> </tbody> </table> **Variable type: character** <table> <thead> <tr> <th style="text-align:left;"> skim_variable </th> <th style="text-align:right;"> n_missing </th> <th style="text-align:right;"> complete_rate </th> <th style="text-align:right;"> min </th> <th style="text-align:right;"> max </th> <th style="text-align:right;"> empty </th> <th style="text-align:right;"> n_unique </th> <th style="text-align:right;"> whitespace </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> t_state </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 45 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> t_county </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 31 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 521 </td> <td style="text-align:right;"> 0 </td> </tr> </tbody> </table> **Variable type: numeric** <table> <thead> <tr> <th style="text-align:left;"> skim_variable </th> <th style="text-align:right;"> n_missing </th> <th style="text-align:right;"> complete_rate </th> <th style="text-align:right;"> mean </th> <th style="text-align:right;"> sd </th> <th style="text-align:right;"> p0 </th> <th style="text-align:right;"> p25 </th> <th style="text-align:right;"> p50 </th> <th style="text-align:right;"> p75 </th> <th style="text-align:right;"> p100 </th> <th style="text-align:left;"> hist </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> xlong </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> -101.65 </td> <td style="text-align:right;"> 12.36 </td> <td style="text-align:right;"> -171.71 </td> <td style="text-align:right;"> -107.41 </td> <td style="text-align:right;"> -100.25 </td> <td style="text-align:right;"> -95.51 </td> <td style="text-align:right;"> 144.72 </td> <td style="text-align:left;"> ▂▇▁▁▁ </td> </tr> <tr> <td style="text-align:left;"> ylat </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 38.40 </td> <td style="text-align:right;"> 5.32 </td> <td style="text-align:right;"> 13.39 </td> <td style="text-align:right;"> 34.69 </td> <td style="text-align:right;"> 37.87 </td> <td style="text-align:right;"> 42.69 </td> <td style="text-align:right;"> 66.84 </td> <td style="text-align:left;"> ▁▃▇▁▁ </td> </tr> </tbody> </table> --- count: false # Data Exploration .panel1-wind1-auto[ ```r *us_wind ``` ] .panel2-wind1-auto[ ``` # A tibble: 58,185 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% * filter(t_state == 'CA') ``` ] .panel2-wind1-auto[ ``` # A tibble: 9,037 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 9,027 more rows ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% filter(t_state == 'CA') %>% * tally() ``` ] .panel2-wind1-auto[ ``` # A tibble: 1 x 1 n <int> 1 9037 ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% filter(t_state == 'CA') %>% tally() *us_wind ``` ] .panel2-wind1-auto[ ``` # A tibble: 1 x 1 n <int> 1 9037 ``` ``` # A tibble: 58,185 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% filter(t_state == 'CA') %>% tally() us_wind %>% * group_by(t_state) ``` ] .panel2-wind1-auto[ ``` # A tibble: 1 x 1 n <int> 1 9037 ``` ``` # A tibble: 58,185 x 4 # Groups: t_state [45] t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% filter(t_state == 'CA') %>% tally() us_wind %>% group_by(t_state) %>% * summarize(n = n()) ``` ] .panel2-wind1-auto[ ``` # A tibble: 1 x 1 n <int> 1 9037 ``` ``` # A tibble: 45 x 2 t_state n <chr> <int> 1 AK 141 2 AR 1 3 AZ 144 4 CA 9037 5 CO 2278 6 CT 3 7 DE 1 8 FL 1 9 GU 1 10 HI 124 # … with 35 more rows ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% filter(t_state == 'CA') %>% tally() us_wind %>% group_by(t_state) %>% summarize(n = n()) %>% * arrange(-n) ``` ] .panel2-wind1-auto[ ``` # A tibble: 1 x 1 n <int> 1 9037 ``` ``` # A tibble: 45 x 2 t_state n <chr> <int> 1 TX 13232 2 CA 9037 3 IA 4280 4 OK 3821 5 KS 2898 6 IL 2602 7 MN 2547 8 CO 2278 9 OR 1868 10 WA 1744 # … with 35 more rows ``` ] --- count: false # Data Exploration .panel1-wind1-auto[ ```r us_wind %>% filter(t_state == 'CA') %>% tally() us_wind %>% group_by(t_state) %>% summarize(n = n()) %>% arrange(-n) %>% * slice(1:5) ``` ] .panel2-wind1-auto[ ``` # A tibble: 1 x 1 n <int> 1 9037 ``` ``` # A tibble: 5 x 2 t_state n <chr> <int> 1 TX 13232 2 CA 9037 3 IA 4280 4 OK 3821 5 KS 2898 ``` ] <style> .panel1-wind1-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-wind1-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-wind1-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Table of California ... <br><br> <table class="table table-condensed"> <thead> <tr> <th style="text-align:right;"> state </th> <th style="text-align:right;"> name </th> <th style="text-align:right;"> aland </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> San Francisco </td> <td style="text-align:right;"> 121455687 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Nevada </td> <td style="text-align:right;"> 2480606160 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Merced </td> <td style="text-align:right;"> 5012175306 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Alpine </td> <td style="text-align:right;"> 1912292633 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Contra Costa </td> <td style="text-align:right;"> 1871930816 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Tulare </td> <td style="text-align:right;"> 12495016292 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Lake </td> <td style="text-align:right;"> 3254288286 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Mono </td> <td style="text-align:right;"> 7896839510 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Imperial </td> <td style="text-align:right;"> 10817291640 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Alameda </td> <td style="text-align:right;"> 1914242789 </td> </tr> </tbody> </table> --- ## Tables can have ... coordinates as numeric fields .pull-left[ <table class="table table-condensed"> <thead> <tr> <th style="text-align:right;"> state </th> <th style="text-align:right;"> name </th> <th style="text-align:right;"> aland </th> <th style="text-align:right;"> X </th> <th style="text-align:right;"> Y </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> San Francisco </td> <td style="text-align:right;"> 121455687 </td> <td style="text-align:right;"> -122.4386 </td> <td style="text-align:right;"> 37.75215 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Nevada </td> <td style="text-align:right;"> 2480606160 </td> <td style="text-align:right;"> -120.7639 </td> <td style="text-align:right;"> 39.30437 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Merced </td> <td style="text-align:right;"> 5012175306 </td> <td style="text-align:right;"> -120.7216 </td> <td style="text-align:right;"> 37.18925 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Alpine </td> <td style="text-align:right;"> 1912292633 </td> <td style="text-align:right;"> -119.8223 </td> <td style="text-align:right;"> 38.59672 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Contra Costa </td> <td style="text-align:right;"> 1871930816 </td> <td style="text-align:right;"> -121.9293 </td> <td style="text-align:right;"> 37.91955 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Tulare </td> <td style="text-align:right;"> 12495016292 </td> <td style="text-align:right;"> -118.8017 </td> <td style="text-align:right;"> 36.22045 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Lake </td> <td style="text-align:right;"> 3254288286 </td> <td style="text-align:right;"> -122.7530 </td> <td style="text-align:right;"> 39.10068 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Mono </td> <td style="text-align:right;"> 7896839510 </td> <td style="text-align:right;"> -118.8847 </td> <td style="text-align:right;"> 37.93879 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Imperial </td> <td style="text-align:right;"> 10817291640 </td> <td style="text-align:right;"> -115.3643 </td> <td style="text-align:right;"> 33.04000 </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Alameda </td> <td style="text-align:right;"> 1914242789 </td> <td style="text-align:right;"> -121.8924 </td> <td style="text-align:right;"> 37.64661 </td> </tr> </tbody> </table> ] .pull-right[ <img src="lecture-02_files/figure-html/unnamed-chunk-6-1.png" width="432" /> ] --- ## Tables can have ... POINT geometries .pull-left[ - <span class = "code">WKT: Well-Known-Text (human readable)</span> - <span class = "code">WKB: Well-Known-Binary (machine and database readable) </span> <table class="table table-condensed"> <thead> <tr> <th style="text-align:right;"> state </th> <th style="text-align:right;"> name </th> <th style="text-align:right;"> geometry </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> San Francisco </td> <td style="text-align:right;"> POINT (-122.4386 37.75215) </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Nevada </td> <td style="text-align:right;"> POINT (-120.7639 39.30437) </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Merced </td> <td style="text-align:right;"> POINT (-120.7216 37.18925) </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Alpine </td> <td style="text-align:right;"> POINT (-119.8223 38.59672) </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Contra Costa </td> <td style="text-align:right;"> POINT (-121.9293 37.91955) </td> </tr> </tbody> </table> ] .pull-right[ <img src="lecture-02_files/figure-html/unnamed-chunk-8-1.png" width="432" /> ] --- count: false #Distance Operators... .panel1-dist-auto[ ```r *st_distance(points) ``` ] .panel2-dist-auto[ ``` Units: [m] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [1,] 0.00 225850.30 163939.93 247216.91 48440.37 365137.23 152430.40 312722.21 827620.19 49462.70 87416.90 128629.70 361555.9 86325.99 262464.35 [2,] 225850.30 0.00 235220.29 113229.65 184292.88 383825.20 172885.53 222941.55 848199.21 208875.60 244500.19 195197.13 152820.6 272586.19 36824.34 [3,] 163939.93 235220.29 0.00 175271.47 133896.55 202227.52 276988.11 182092.36 670820.25 115227.81 86475.90 47777.44 387473.8 114870.06 266225.04 [4,] 247216.91 113229.65 175271.47 0.00 198777.83 279176.60 259898.05 109779.29 736878.31 209645.13 223816.18 154648.93 240044.5 257190.09 124793.33 [5,] 48440.37 184292.88 133896.55 198777.83 0.00 335668.69 149616.19 267029.50 804421.91 30522.90 79256.31 91202.80 326996.8 96280.91 221116.51 [6,] 365137.23 383825.20 202227.52 279176.60 335668.69 0.00 472717.79 191212.59 473190.83 317168.53 281403.16 245526.23 518987.5 300628.75 402754.94 [7,] 152430.40 172885.53 276988.11 259898.05 149616.19 472717.79 0.00 360442.67 945458.47 178240.36 227477.79 229859.59 254004.1 236578.72 198986.90 [8,] 312722.21 222941.55 182092.36 109779.29 267029.50 191212.59 360442.67 0.00 630984.89 266262.92 259964.03 190550.02 337599.1 292350.59 231117.72 [9,] 827620.19 848199.21 670820.25 736878.31 804421.91 473190.83 945458.47 630984.89 0.00 782543.23 740457.39 716536.29 967331.8 751320.81 861160.72 [10,] 49462.70 208875.60 115227.81 209645.13 30522.90 317168.53 178240.36 266262.92 782543.23 0.00 49334.46 79399.62 354621.1 66458.17 245546.41 [11,] 87416.90 244500.19 86475.90 223816.18 79256.31 281403.16 227477.79 259964.03 740457.39 49334.46 0.00 71662.80 394388.0 33660.67 280325.72 [12,] 128629.70 195197.13 47777.44 154648.93 91202.80 245526.23 229859.59 190550.02 716536.29 79399.62 71662.80 0.00 348012.3 105252.27 228362.68 [13,] 361555.89 152820.61 387473.84 240044.46 326996.83 518987.45 254004.09 337599.13 967331.78 354621.08 394387.98 348012.34 0.0 420348.54 121793.75 [14,] 86325.99 272586.19 114870.06 257190.09 96280.91 300628.75 236578.72 292350.59 751320.81 66458.17 33660.67 105252.27 420348.5 0.00 308895.43 [15,] 262464.35 36824.34 266225.04 124793.33 221116.51 402754.94 198986.90 231117.72 861160.72 245546.41 280325.72 228362.68 121793.8 308895.43 0.00 [16,] 84456.21 162127.25 203668.31 218519.87 74230.06 402471.51 75386.62 307733.77 873976.48 103150.56 152477.25 157442.89 283193.7 163900.73 196496.69 [17,] 159653.98 127289.56 257669.21 218457.65 142503.22 446419.19 45680.24 322114.91 919565.14 172949.38 221604.18 209892.49 217133.0 236905.94 153536.22 [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30] [1,] 84456.21 159653.98 123393.77 156587.30 223580.05 350099.05 205417.42 173899.57 243026.69 220263.95 336660.23 286170.44 113625.68 426098.62 270361.14 [2,] 162127.25 127289.56 107338.60 85661.93 205745.84 307027.81 143727.96 95881.25 248047.35 158581.16 195333.57 78104.38 120167.46 475714.97 299478.37 [3,] 203668.31 257669.21 150510.33 222062.73 84003.34 475943.15 305018.26 139866.33 84446.16 115134.59 413513.45 313198.06 195657.34 272136.36 106540.30 [4,] 218519.87 218457.65 133268.26 169312.22 113322.98 418309.82 248312.78 74566.94 153720.32 64411.91 306754.56 179298.73 180817.99 374507.51 205043.50 [5,] 74230.06 142503.22 78205.11 125585.92 181705.65 351343.67 191057.71 125633.70 205914.28 173665.86 316441.89 250266.53 84900.53 404490.91 239292.55 [6,] 402471.51 446419.19 334597.89 403384.47 180329.21 665366.33 490268.88 296913.06 140200.55 225263.52 578427.60 456904.03 387028.87 97657.83 96596.91 [7,] 75386.62 45680.24 142007.54 91704.63 300271.00 201737.43 63458.27 195694.10 334709.71 271174.36 194684.26 192444.30 87137.23 549003.28 376654.38 [8,] 307733.77 322114.91 222220.13 273161.03 98392.77 527566.23 355816.58 164873.96 112011.80 94106.80 415051.16 285092.81 275875.73 288838.53 147758.78 [9,] 873976.48 919565.14 807743.75 875945.19 651565.14 1138272.77 962946.47 767514.85 612981.04 692478.25 1043305.62 915511.19 860155.03 401577.34 568818.86 [10,] 103150.56 172949.38 101542.15 155223.14 174970.87 379860.89 221440.53 139984.02 193564.19 175499.69 346882.18 277608.24 115218.14 381539.14 221768.02 [11,] 152477.25 221604.18 139137.19 200467.15 162700.90 428988.87 270235.18 163033.49 170717.93 177231.22 393976.97 317262.73 162417.97 338885.25 189160.24 [12,] 157442.89 209892.49 103707.26 174941.30 96119.49 428255.42 257300.90 103101.08 115134.89 105569.87 367588.88 272321.04 147887.69 319164.54 148935.44 [13,] 283193.65 217133.04 255275.57 205036.96 348917.19 276913.47 194130.65 247622.71 390997.18 299304.75 122451.89 77154.20 247971.81 614549.82 442888.79 [14,] 163900.73 236905.94 165711.42 221639.74 194510.96 436031.53 284817.70 194830.21 199145.04 210792.66 412348.77 343231.62 181140.79 350409.66 212041.86 [15,] 196496.69 153536.22 144009.27 117559.40 228578.82 311008.07 160313.55 126443.94 270901.61 179495.54 184394.19 54506.04 155079.27 496753.62 322777.13 [16,] 0.00 75198.08 86388.21 80585.25 236050.80 277115.38 121548.39 145977.08 267021.30 214531.91 252209.12 210391.56 42270.73 475745.60 305935.83 [17,] 75198.08 0.00 111823.13 49205.06 269613.17 219388.17 48730.10 158976.78 306681.39 235964.89 177025.92 150668.73 62185.13 527233.97 351704.32 [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [1,] 298588.85 104306.65 538456.52 475077.12 407288.20 43259.05 647681.3 466933.8 451211.4 192775.12 176213.40 264546.34 427148.5 460826.3 617000.34 [2,] 368745.89 158668.51 599687.88 560522.75 521438.24 218285.79 641652.5 428060.8 254146.3 50984.82 301575.23 155695.04 295566.1 378912.0 678142.31 [3,] 147997.15 96035.90 391527.68 338800.20 289048.26 201516.82 485009.5 304493.5 489315.8 237209.22 72144.06 352087.88 513977.4 574868.6 471291.67 [4,] 280518.00 146543.59 497797.44 466352.17 438886.69 259467.37 529057.5 314903.2 341538.2 151840.16 247407.35 268389.88 405505.9 492026.2 574793.90 [5,] 278057.21 57567.77 521301.89 462804.86 401561.95 71375.06 618232.3 430034.6 420893.1 157625.88 165013.69 246803.30 411776.9 457016.1 600721.41 [6,] 92554.65 290463.31 219019.52 199261.68 206241.14 403689.79 282790.4 129055.6 619739.8 406020.47 207297.33 527936.49 679205.1 755287.8 295621.13 [7,] 424470.73 182759.32 668219.84 611826.77 551069.97 114510.73 751780.5 550865.6 325797.3 121945.67 314625.16 122271.32 277689.0 309255.2 747903.00 [8,] 223249.52 209463.62 408094.21 389037.53 379236.16 336402.03 421173.6 205816.4 435329.0 260275.63 243752.12 378145.19 512487.2 601451.6 481870.76 [9,] 529068.61 762783.71 300149.62 378261.80 465674.40 868860.99 213819.2 428568.4 1061746.2 875972.45 654099.40 998032.08 1142375.2 1225225.5 234684.42 [10,] 254333.46 63102.58 496481.96 436124.40 372968.10 86702.67 599928.7 417508.5 449714.6 185845.62 137102.06 277326.20 442295.5 486583.9 575611.43 [11,] 211390.55 86619.39 451163.16 388817.85 324033.96 129828.09 562927.7 389949.5 491802.7 228015.64 89396.67 325326.26 490392.5 535916.2 529855.57 [12,] 195734.87 48260.91 439133.47 386450.72 334856.45 161711.74 527623.7 339432.6 448865.4 192146.94 106444.29 305016.96 467657.6 527180.5 518914.30 [13,] 515776.08 310074.38 737792.46 705064.42 671245.23 342220.57 755506.3 539218.4 102599.6 169530.84 454394.92 151982.06 192634.4 300934.2 814492.12 [14,] 223986.72 117128.99 458012.48 391824.12 321678.12 129271.76 579599.2 414106.4 516050.0 252062.10 97450.30 341993.37 506575.1 545780.5 535637.76 [15,] 394583.58 194067.96 620530.21 584878.28 549516.44 253628.21 652242.9 436827.6 224298.7 79476.96 334287.27 158531.83 281434.0 372621.7 698206.94 [16,] 350321.44 112363.57 593988.92 536681.58 475736.91 59137.24 683575.4 487883.9 369080.7 119404.00 239241.96 180214.10 343570.2 383497.5 673575.26 [17,] 405539.92 161633.69 648498.67 596080.17 540358.44 130258.71 722103.2 517254.0 296956.9 76316.42 304096.78 105328.14 269675.7 317869.1 728293.81 [,46] [,47] [,48] [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [1,] 208657.06 202485.58 736297.2 172732.29 201066.50 732303.73 225069.98 37917.41 95246.15 327194.79 205214.51 72331.25 319584.12 [2,] 27067.52 61895.62 785218.3 123567.16 345676.32 750522.06 82496.41 249714.35 203190.07 249943.83 226339.22 153604.19 436611.86 [3,] 208335.01 177717.77 587236.8 113942.29 117404.18 574254.35 286091.18 144383.38 241978.76 436743.67 341917.26 160611.07 202283.16 [4,] 93791.94 64204.05 678175.9 77163.69 292567.55 639408.20 194281.85 255355.18 266970.41 362704.95 322266.83 187685.52 360455.73 [5,] 164777.45 155474.93 718333.6 124570.39 198812.56 708029.95 196486.95 65423.02 108130.05 320060.13 211461.34 38768.23 312667.20 [6,] 358533.27 322588.05 401594.4 269754.79 218673.26 375676.65 455185.23 341093.35 443356.54 619125.91 539022.26 358864.58 171467.10 [7,] 175118.37 196064.51 864224.8 215384.31 347070.00 848205.49 117345.83 190243.97 64476.49 174765.94 66699.38 116618.31 462216.42 [8,] 203118.13 170792.51 579011.4 149049.86 283225.32 534031.60 303956.97 308338.88 356098.40 472455.01 425228.51 269459.61 314240.52 [9,] 824697.58 789152.33 127658.7 741244.82 643120.16 97848.69 924212.25 798016.38 912531.63 1090533.28 1011483.53 830510.19 531685.93 [10,] 187523.62 173710.16 693976.4 132856.06 169079.85 686680.34 226188.05 45731.90 131609.42 349960.54 238310.14 69219.07 284211.35 [11,] 220705.26 200546.29 648969.7 147803.61 119746.28 645388.58 271110.57 59708.46 178594.50 399218.92 286730.80 117224.51 235430.67 [12,] 168963.04 141993.20 634512.3 81816.10 150550.40 619640.37 240361.26 118263.34 197975.46 389044.42 295242.58 113997.31 247116.82 [13,] 179333.58 210524.31 915805.0 274355.29 498452.18 870902.61 140803.85 391159.38 309017.58 212883.89 274733.52 291140.87 587799.85 [14,] 249783.56 231646.32 655780.5 180842.98 115558.56 657404.03 292599.79 49720.78 181546.67 410761.74 291463.64 134947.31 234680.17 [15,] 59894.39 88791.75 802759.8 152706.83 378857.82 763821.66 92922.07 286537.43 235360.97 250498.07 246515.21 190161.54 466035.36 [16,] 152452.68 159993.07 790499.5 158722.10 272207.67 777070.92 143680.59 120579.73 48722.54 247287.73 138396.51 43610.37 386863.05 [17,] 130754.85 154260.83 842731.8 181568.62 340594.48 821940.97 76803.69 195454.21 91894.48 179827.81 103809.55 104500.00 451504.74 [ reached getOption("max.print") -- omitted 41 rows ] ``` ] --- count: false #Distance Operators... .panel1-dist-auto[ ```r st_distance(points) %>% * units::drop_units() ``` ] .panel2-dist-auto[ ``` [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [1,] 0.00 225850.30 163939.93 247216.91 48440.37 365137.23 152430.40 312722.21 827620.19 49462.70 87416.90 128629.70 361555.9 86325.99 262464.35 [2,] 225850.30 0.00 235220.29 113229.65 184292.88 383825.20 172885.53 222941.55 848199.21 208875.60 244500.19 195197.13 152820.6 272586.19 36824.34 [3,] 163939.93 235220.29 0.00 175271.47 133896.55 202227.52 276988.11 182092.36 670820.25 115227.81 86475.90 47777.44 387473.8 114870.06 266225.04 [4,] 247216.91 113229.65 175271.47 0.00 198777.83 279176.60 259898.05 109779.29 736878.31 209645.13 223816.18 154648.93 240044.5 257190.09 124793.33 [5,] 48440.37 184292.88 133896.55 198777.83 0.00 335668.69 149616.19 267029.50 804421.91 30522.90 79256.31 91202.80 326996.8 96280.91 221116.51 [6,] 365137.23 383825.20 202227.52 279176.60 335668.69 0.00 472717.79 191212.59 473190.83 317168.53 281403.16 245526.23 518987.5 300628.75 402754.94 [7,] 152430.40 172885.53 276988.11 259898.05 149616.19 472717.79 0.00 360442.67 945458.47 178240.36 227477.79 229859.59 254004.1 236578.72 198986.90 [8,] 312722.21 222941.55 182092.36 109779.29 267029.50 191212.59 360442.67 0.00 630984.89 266262.92 259964.03 190550.02 337599.1 292350.59 231117.72 [9,] 827620.19 848199.21 670820.25 736878.31 804421.91 473190.83 945458.47 630984.89 0.00 782543.23 740457.39 716536.29 967331.8 751320.81 861160.72 [10,] 49462.70 208875.60 115227.81 209645.13 30522.90 317168.53 178240.36 266262.92 782543.23 0.00 49334.46 79399.62 354621.1 66458.17 245546.41 [11,] 87416.90 244500.19 86475.90 223816.18 79256.31 281403.16 227477.79 259964.03 740457.39 49334.46 0.00 71662.80 394388.0 33660.67 280325.72 [12,] 128629.70 195197.13 47777.44 154648.93 91202.80 245526.23 229859.59 190550.02 716536.29 79399.62 71662.80 0.00 348012.3 105252.27 228362.68 [13,] 361555.89 152820.61 387473.84 240044.46 326996.83 518987.45 254004.09 337599.13 967331.78 354621.08 394387.98 348012.34 0.0 420348.54 121793.75 [14,] 86325.99 272586.19 114870.06 257190.09 96280.91 300628.75 236578.72 292350.59 751320.81 66458.17 33660.67 105252.27 420348.5 0.00 308895.43 [15,] 262464.35 36824.34 266225.04 124793.33 221116.51 402754.94 198986.90 231117.72 861160.72 245546.41 280325.72 228362.68 121793.8 308895.43 0.00 [16,] 84456.21 162127.25 203668.31 218519.87 74230.06 402471.51 75386.62 307733.77 873976.48 103150.56 152477.25 157442.89 283193.7 163900.73 196496.69 [17,] 159653.98 127289.56 257669.21 218457.65 142503.22 446419.19 45680.24 322114.91 919565.14 172949.38 221604.18 209892.49 217133.0 236905.94 153536.22 [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30] [1,] 84456.21 159653.98 123393.77 156587.30 223580.05 350099.05 205417.42 173899.57 243026.69 220263.95 336660.23 286170.44 113625.68 426098.62 270361.14 [2,] 162127.25 127289.56 107338.60 85661.93 205745.84 307027.81 143727.96 95881.25 248047.35 158581.16 195333.57 78104.38 120167.46 475714.97 299478.37 [3,] 203668.31 257669.21 150510.33 222062.73 84003.34 475943.15 305018.26 139866.33 84446.16 115134.59 413513.45 313198.06 195657.34 272136.36 106540.30 [4,] 218519.87 218457.65 133268.26 169312.22 113322.98 418309.82 248312.78 74566.94 153720.32 64411.91 306754.56 179298.73 180817.99 374507.51 205043.50 [5,] 74230.06 142503.22 78205.11 125585.92 181705.65 351343.67 191057.71 125633.70 205914.28 173665.86 316441.89 250266.53 84900.53 404490.91 239292.55 [6,] 402471.51 446419.19 334597.89 403384.47 180329.21 665366.33 490268.88 296913.06 140200.55 225263.52 578427.60 456904.03 387028.87 97657.83 96596.91 [7,] 75386.62 45680.24 142007.54 91704.63 300271.00 201737.43 63458.27 195694.10 334709.71 271174.36 194684.26 192444.30 87137.23 549003.28 376654.38 [8,] 307733.77 322114.91 222220.13 273161.03 98392.77 527566.23 355816.58 164873.96 112011.80 94106.80 415051.16 285092.81 275875.73 288838.53 147758.78 [9,] 873976.48 919565.14 807743.75 875945.19 651565.14 1138272.77 962946.47 767514.85 612981.04 692478.25 1043305.62 915511.19 860155.03 401577.34 568818.86 [10,] 103150.56 172949.38 101542.15 155223.14 174970.87 379860.89 221440.53 139984.02 193564.19 175499.69 346882.18 277608.24 115218.14 381539.14 221768.02 [11,] 152477.25 221604.18 139137.19 200467.15 162700.90 428988.87 270235.18 163033.49 170717.93 177231.22 393976.97 317262.73 162417.97 338885.25 189160.24 [12,] 157442.89 209892.49 103707.26 174941.30 96119.49 428255.42 257300.90 103101.08 115134.89 105569.87 367588.88 272321.04 147887.69 319164.54 148935.44 [13,] 283193.65 217133.04 255275.57 205036.96 348917.19 276913.47 194130.65 247622.71 390997.18 299304.75 122451.89 77154.20 247971.81 614549.82 442888.79 [14,] 163900.73 236905.94 165711.42 221639.74 194510.96 436031.53 284817.70 194830.21 199145.04 210792.66 412348.77 343231.62 181140.79 350409.66 212041.86 [15,] 196496.69 153536.22 144009.27 117559.40 228578.82 311008.07 160313.55 126443.94 270901.61 179495.54 184394.19 54506.04 155079.27 496753.62 322777.13 [16,] 0.00 75198.08 86388.21 80585.25 236050.80 277115.38 121548.39 145977.08 267021.30 214531.91 252209.12 210391.56 42270.73 475745.60 305935.83 [17,] 75198.08 0.00 111823.13 49205.06 269613.17 219388.17 48730.10 158976.78 306681.39 235964.89 177025.92 150668.73 62185.13 527233.97 351704.32 [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [1,] 298588.85 104306.65 538456.52 475077.12 407288.20 43259.05 647681.3 466933.8 451211.4 192775.12 176213.40 264546.34 427148.5 460826.3 617000.34 [2,] 368745.89 158668.51 599687.88 560522.75 521438.24 218285.79 641652.5 428060.8 254146.3 50984.82 301575.23 155695.04 295566.1 378912.0 678142.31 [3,] 147997.15 96035.90 391527.68 338800.20 289048.26 201516.82 485009.5 304493.5 489315.8 237209.22 72144.06 352087.88 513977.4 574868.6 471291.67 [4,] 280518.00 146543.59 497797.44 466352.17 438886.69 259467.37 529057.5 314903.2 341538.2 151840.16 247407.35 268389.88 405505.9 492026.2 574793.90 [5,] 278057.21 57567.77 521301.89 462804.86 401561.95 71375.06 618232.3 430034.6 420893.1 157625.88 165013.69 246803.30 411776.9 457016.1 600721.41 [6,] 92554.65 290463.31 219019.52 199261.68 206241.14 403689.79 282790.4 129055.6 619739.8 406020.47 207297.33 527936.49 679205.1 755287.8 295621.13 [7,] 424470.73 182759.32 668219.84 611826.77 551069.97 114510.73 751780.5 550865.6 325797.3 121945.67 314625.16 122271.32 277689.0 309255.2 747903.00 [8,] 223249.52 209463.62 408094.21 389037.53 379236.16 336402.03 421173.6 205816.4 435329.0 260275.63 243752.12 378145.19 512487.2 601451.6 481870.76 [9,] 529068.61 762783.71 300149.62 378261.80 465674.40 868860.99 213819.2 428568.4 1061746.2 875972.45 654099.40 998032.08 1142375.2 1225225.5 234684.42 [10,] 254333.46 63102.58 496481.96 436124.40 372968.10 86702.67 599928.7 417508.5 449714.6 185845.62 137102.06 277326.20 442295.5 486583.9 575611.43 [11,] 211390.55 86619.39 451163.16 388817.85 324033.96 129828.09 562927.7 389949.5 491802.7 228015.64 89396.67 325326.26 490392.5 535916.2 529855.57 [12,] 195734.87 48260.91 439133.47 386450.72 334856.45 161711.74 527623.7 339432.6 448865.4 192146.94 106444.29 305016.96 467657.6 527180.5 518914.30 [13,] 515776.08 310074.38 737792.46 705064.42 671245.23 342220.57 755506.3 539218.4 102599.6 169530.84 454394.92 151982.06 192634.4 300934.2 814492.12 [14,] 223986.72 117128.99 458012.48 391824.12 321678.12 129271.76 579599.2 414106.4 516050.0 252062.10 97450.30 341993.37 506575.1 545780.5 535637.76 [15,] 394583.58 194067.96 620530.21 584878.28 549516.44 253628.21 652242.9 436827.6 224298.7 79476.96 334287.27 158531.83 281434.0 372621.7 698206.94 [16,] 350321.44 112363.57 593988.92 536681.58 475736.91 59137.24 683575.4 487883.9 369080.7 119404.00 239241.96 180214.10 343570.2 383497.5 673575.26 [17,] 405539.92 161633.69 648498.67 596080.17 540358.44 130258.71 722103.2 517254.0 296956.9 76316.42 304096.78 105328.14 269675.7 317869.1 728293.81 [,46] [,47] [,48] [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [1,] 208657.06 202485.58 736297.2 172732.29 201066.50 732303.73 225069.98 37917.41 95246.15 327194.79 205214.51 72331.25 319584.12 [2,] 27067.52 61895.62 785218.3 123567.16 345676.32 750522.06 82496.41 249714.35 203190.07 249943.83 226339.22 153604.19 436611.86 [3,] 208335.01 177717.77 587236.8 113942.29 117404.18 574254.35 286091.18 144383.38 241978.76 436743.67 341917.26 160611.07 202283.16 [4,] 93791.94 64204.05 678175.9 77163.69 292567.55 639408.20 194281.85 255355.18 266970.41 362704.95 322266.83 187685.52 360455.73 [5,] 164777.45 155474.93 718333.6 124570.39 198812.56 708029.95 196486.95 65423.02 108130.05 320060.13 211461.34 38768.23 312667.20 [6,] 358533.27 322588.05 401594.4 269754.79 218673.26 375676.65 455185.23 341093.35 443356.54 619125.91 539022.26 358864.58 171467.10 [7,] 175118.37 196064.51 864224.8 215384.31 347070.00 848205.49 117345.83 190243.97 64476.49 174765.94 66699.38 116618.31 462216.42 [8,] 203118.13 170792.51 579011.4 149049.86 283225.32 534031.60 303956.97 308338.88 356098.40 472455.01 425228.51 269459.61 314240.52 [9,] 824697.58 789152.33 127658.7 741244.82 643120.16 97848.69 924212.25 798016.38 912531.63 1090533.28 1011483.53 830510.19 531685.93 [10,] 187523.62 173710.16 693976.4 132856.06 169079.85 686680.34 226188.05 45731.90 131609.42 349960.54 238310.14 69219.07 284211.35 [11,] 220705.26 200546.29 648969.7 147803.61 119746.28 645388.58 271110.57 59708.46 178594.50 399218.92 286730.80 117224.51 235430.67 [12,] 168963.04 141993.20 634512.3 81816.10 150550.40 619640.37 240361.26 118263.34 197975.46 389044.42 295242.58 113997.31 247116.82 [13,] 179333.58 210524.31 915805.0 274355.29 498452.18 870902.61 140803.85 391159.38 309017.58 212883.89 274733.52 291140.87 587799.85 [14,] 249783.56 231646.32 655780.5 180842.98 115558.56 657404.03 292599.79 49720.78 181546.67 410761.74 291463.64 134947.31 234680.17 [15,] 59894.39 88791.75 802759.8 152706.83 378857.82 763821.66 92922.07 286537.43 235360.97 250498.07 246515.21 190161.54 466035.36 [16,] 152452.68 159993.07 790499.5 158722.10 272207.67 777070.92 143680.59 120579.73 48722.54 247287.73 138396.51 43610.37 386863.05 [17,] 130754.85 154260.83 842731.8 181568.62 340594.48 821940.97 76803.69 195454.21 91894.48 179827.81 103809.55 104500.00 451504.74 [ reached getOption("max.print") -- omitted 41 rows ] ``` ] --- count: false #Distance Operators... .panel1-dist-auto[ ```r st_distance(points) %>% units::drop_units() -> * dist_m ``` ] .panel2-dist-auto[ ] --- count: false #Distance Operators... .panel1-dist-auto[ ```r st_distance(points) %>% units::drop_units() -> dist_m *dist_mi = 1/dist_m # qgraph requires a similarity matrix ``` ] .panel2-dist-auto[ ] --- count: false #Distance Operators... .panel1-dist-auto[ ```r st_distance(points) %>% units::drop_units() -> dist_m dist_mi = 1/dist_m # qgraph requires a similarity matrix *qgraph(dist_mi, layout='spring', vsize=4, labels = points$name) ``` ] .panel2-dist-auto[ <img src="lecture-02_files/figure-html/dist_auto_05_output-1.png" width="432" /> ] <style> .panel1-dist-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-dist-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-dist-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false #Geometric Operators... .panel1-bbox-auto[ ```r *st_bbox(points) ``` ] .panel2-bbox-auto[ ``` xmin ymin xmax ymax -123.89729 33.03449 -115.36435 41.74200 ``` ] --- count: false #Geometric Operators... .panel1-bbox-auto[ ```r st_bbox(points) %>% * st_as_sfc() ``` ] .panel2-bbox-auto[ ``` Geometry set for 1 feature Geometry type: POLYGON Dimension: XY Bounding box: xmin: -123.8973 ymin: 33.03449 xmax: -115.3643 ymax: 41.742 Geodetic CRS: NAD83 ``` ] --- count: false #Geometric Operators... .panel1-bbox-auto[ ```r st_bbox(points) %>% st_as_sfc() %>% * ggplot() ``` ] .panel2-bbox-auto[ <img src="lecture-02_files/figure-html/bbox_auto_03_output-1.png" width="432" /> ] --- count: false #Geometric Operators... .panel1-bbox-auto[ ```r st_bbox(points) %>% st_as_sfc() %>% ggplot() + * geom_sf() ``` ] .panel2-bbox-auto[ <img src="lecture-02_files/figure-html/bbox_auto_04_output-1.png" width="432" /> ] --- count: false #Geometric Operators... .panel1-bbox-auto[ ```r st_bbox(points) %>% st_as_sfc() %>% ggplot() + geom_sf() + * geom_sf(data = points, col = "darkred") ``` ] .panel2-bbox-auto[ <img src="lecture-02_files/figure-html/bbox_auto_05_output-1.png" width="432" /> ] <style> .panel1-bbox-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-bbox-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-bbox-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- ## Tables can have ... POLYGON geometries .pull-left[ <table class="table table-condensed"> <thead> <tr> <th style="text-align:right;"> state </th> <th style="text-align:right;"> name </th> <th style="text-align:right;"> geometry </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> San Francisco </td> <td style="text-align:right;"> MULTIPOLYGON (((-122.512 37... </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Nevada </td> <td style="text-align:right;"> MULTIPOLYGON (((-121.2661 3... </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Merced </td> <td style="text-align:right;"> MULTIPOLYGON (((-121.2268 3... </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Alpine </td> <td style="text-align:right;"> MULTIPOLYGON (((-120.0725 3... </td> </tr> <tr> <td style="text-align:right;"> CA </td> <td style="text-align:right;"> Contra Costa </td> <td style="text-align:right;"> MULTIPOLYGON (((-122.4253 3... </td> </tr> </tbody> </table> ] .pull-right[ <img src="lecture-02_files/figure-html/unnamed-chunk-10-1.png" width="432" /> ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r *poly ``` ] .panel2-area-auto[ ``` Simple feature collection with 58 features and 2 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -124.4096 ymin: 32.53416 xmax: -114.1391 ymax: 42.00925 Geodetic CRS: NAD83 First 10 features: state name geometry 1 CA San Francisco MULTIPOLYGON (((-122.512 37... 2 CA Nevada MULTIPOLYGON (((-121.2661 3... 3 CA Merced MULTIPOLYGON (((-121.2268 3... 4 CA Alpine MULTIPOLYGON (((-120.0725 3... 5 CA Contra Costa MULTIPOLYGON (((-122.4253 3... 6 CA Tulare MULTIPOLYGON (((-119.5461 3... 7 CA Lake MULTIPOLYGON (((-123.0778 3... 8 CA Mono MULTIPOLYGON (((-119.6392 3... 9 CA Imperial MULTIPOLYGON (((-116.1056 3... 10 CA Alameda MULTIPOLYGON (((-122.3337 3... ``` ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r poly %>% * mutate(area = as.numeric(st_area(.) /1e6)) ``` ] .panel2-area-auto[ ``` Simple feature collection with 58 features and 3 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -124.4096 ymin: 32.53416 xmax: -114.1391 ymax: 42.00925 Geodetic CRS: NAD83 First 10 features: state name geometry area 1 CA San Francisco MULTIPOLYGON (((-122.512 37... 113.9176 2 CA Nevada MULTIPOLYGON (((-121.2661 3... 2480.4565 3 CA Merced MULTIPOLYGON (((-121.2268 3... 5138.2737 4 CA Alpine MULTIPOLYGON (((-120.0725 3... 1930.8945 5 CA Contra Costa MULTIPOLYGON (((-122.4253 3... 1956.0298 6 CA Tulare MULTIPOLYGON (((-119.5461 3... 12510.9144 7 CA Lake MULTIPOLYGON (((-123.0778 3... 3428.8614 8 CA Mono MULTIPOLYGON (((-119.6392 3... 8105.4794 9 CA Imperial MULTIPOLYGON (((-116.1056 3... 11554.3166 10 CA Alameda MULTIPOLYGON (((-122.3337 3... 1965.7779 ``` ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r poly %>% mutate(area = as.numeric(st_area(.) /1e6)) %>% * ggplot() ``` ] .panel2-area-auto[ <img src="lecture-02_files/figure-html/area_auto_03_output-1.png" width="432" /> ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r poly %>% mutate(area = as.numeric(st_area(.) /1e6)) %>% ggplot() + * geom_col(aes(x = reorder(name, -area), y = area)) ``` ] .panel2-area-auto[ <img src="lecture-02_files/figure-html/area_auto_04_output-1.png" width="432" /> ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r poly %>% mutate(area = as.numeric(st_area(.) /1e6)) %>% ggplot() + geom_col(aes(x = reorder(name, -area), y = area)) + * labs(title = "Area per state", * y = "Area Km^2", * x = "State") ``` ] .panel2-area-auto[ <img src="lecture-02_files/figure-html/area_auto_05_output-1.png" width="432" /> ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r poly %>% mutate(area = as.numeric(st_area(.) /1e6)) %>% ggplot() + geom_col(aes(x = reorder(name, -area), y = area)) + labs(title = "Area per state", y = "Area Km^2", x = "State") + * theme_light() ``` ] .panel2-area-auto[ <img src="lecture-02_files/figure-html/area_auto_06_output-1.png" width="432" /> ] --- count: false #Polygon Operators... .panel1-area-auto[ ```r poly %>% mutate(area = as.numeric(st_area(.) /1e6)) %>% ggplot() + geom_col(aes(x = reorder(name, -area), y = area)) + labs(title = "Area per state", y = "Area Km^2", x = "State") + theme_light() + * theme(axis.text.x = element_text(angle = 90)) ``` ] .panel2-area-auto[ <img src="lecture-02_files/figure-html/area_auto_07_output-1.png" width="432" /> ] <style> .panel1-area-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-area-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-area-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false #Geometric Operators... .panel1-dissolve-auto[ ```r *ca ``` ] .panel2-dissolve-auto[ ``` Simple feature collection with 58 features and 12 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -124.4096 ymin: 32.53416 xmax: -114.1391 ymax: 42.00925 Geodetic CRS: NAD83 First 10 features: statefp countyfp countyns affgeoid geoid name lsad aland awater state_name state_abbr jurisdiction_type geometry 76 06 075 00277302 0500000US06075 06075 San Francisco 06 121455687 479136515 California CA state MULTIPOLYGON (((-122.512 37... 371 06 057 01682927 0500000US06057 06057 Nevada 06 2480606160 41513172 California CA state MULTIPOLYGON (((-121.2661 3... 636 06 047 00277288 0500000US06047 06047 Merced 06 5012175306 112509475 California CA state MULTIPOLYGON (((-121.2268 3... 714 06 003 01675840 0500000US06003 06003 Alpine 06 1912292633 12557304 California CA state MULTIPOLYGON (((-120.0725 3... 717 06 013 01675903 0500000US06013 06013 Contra Costa 06 1871930816 209819213 California CA state MULTIPOLYGON (((-122.4253 3... 774 06 107 00277318 0500000US06107 06107 Tulare 06 12495016292 37081410 California CA state MULTIPOLYGON (((-119.5461 3... 803 06 033 00277281 0500000US06033 06033 Lake 06 3254288286 188912510 California CA state MULTIPOLYGON (((-123.0778 3... 898 06 051 00277290 0500000US06051 06051 Mono 06 7896839510 214694734 California CA state MULTIPOLYGON (((-119.6392 3... 953 06 025 00277277 0500000US06025 06025 Imperial 06 10817291640 790230304 California CA state MULTIPOLYGON (((-116.1056 3... 982 06 001 01675839 0500000US06001 06001 Alameda 06 1914242789 212979931 California CA state MULTIPOLYGON (((-122.3337 3... ``` ] --- count: false #Geometric Operators... .panel1-dissolve-auto[ ```r ca %>% *st_union() ``` ] .panel2-dissolve-auto[ ``` Geometry set for 1 feature Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -124.4096 ymin: 32.53416 xmax: -114.1391 ymax: 42.00925 Geodetic CRS: NAD83 ``` ] --- count: false #Geometric Operators... .panel1-dissolve-auto[ ```r ca %>% st_union() %>% * ggplot() ``` ] .panel2-dissolve-auto[ <img src="lecture-02_files/figure-html/dissolve_auto_03_output-1.png" width="432" /> ] --- count: false #Geometric Operators... .panel1-dissolve-auto[ ```r ca %>% st_union() %>% ggplot() + * geom_sf() ``` ] .panel2-dissolve-auto[ <img src="lecture-02_files/figure-html/dissolve_auto_04_output-1.png" width="432" /> ] --- count: false #Geometric Operators... .panel1-dissolve-auto[ ```r ca %>% st_union() %>% ggplot() + geom_sf() + * theme_bw() ``` ] .panel2-dissolve-auto[ <img src="lecture-02_files/figure-html/dissolve_auto_05_output-1.png" width="432" /> ] <style> .panel1-dissolve-auto { color: black; width: 29.1%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-dissolve-auto { color: black; width: 67.9%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-dissolve-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- ## Coordinate Reference Systems A data structure cannot be considered spatial unless it is accompanied by coordinate reference system (CRS) - They describe the reference _origin_ and the reference _units_ so that coordinates become spatially meaningful! <img src="lecture-02_files/figure-html/unnamed-chunk-11-1.png" width="432" /><img src="lecture-02_files/figure-html/unnamed-chunk-11-2.png" width="432" /> --- .pull-left[ ```r st_crs(poly)$input ``` ``` [1] "EPSG:4269" ``` ```r st_crs(poly)$wkt ``` ``` [1] "GEOGCRS[\"NAD83\",\n DATUM[\"North American Datum 1983\",\n ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"Geodesy.\"],\n 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.\"],\n BBOX[14.92,167.65,86.46,-47.74]],\n ID[\"EPSG\",4269]]" ``` ] .pull-right[ ```r st_crs(st_transform(poly, 5070))$input ``` ``` [1] "EPSG:5070" ``` ```r st_crs(st_transform(poly, 5070))$wkt ``` ``` [1] "PROJCRS[\"NAD83 / Conus Albers\",\n BASEGEOGCRS[\"NAD83\",\n DATUM[\"North American Datum 1983\",\n ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4269]],\n CONVERSION[\"Conus Albers\",\n METHOD[\"Albers Equal Area\",\n ID[\"EPSG\",9822]],\n PARAMETER[\"Latitude of false origin\",23,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8821]],\n PARAMETER[\"Longitude of false origin\",-96,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8822]],\n PARAMETER[\"Latitude of 1st standard parallel\",29.5,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8823]],\n PARAMETER[\"Latitude of 2nd standard parallel\",45.5,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8824]],\n PARAMETER[\"Easting at false origin\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8826]],\n PARAMETER[\"Northing at false origin\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8827]]],\n CS[Cartesian,2],\n AXIS[\"easting (X)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"northing (Y)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"Data analysis and small scale data presentation for contiguous lower 48 states.\"],\n AREA[\"United States (USA) - CONUS onshore - Alabama; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; 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.\"],\n BBOX[24.41,-124.79,49.38,-66.91]],\n ID[\"EPSG\",5070]]" ``` ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r *us_wind ``` ] .panel2-wind2-auto[ ``` # A tibble: 58,185 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% * filter(!t_state %in% c("AK", "PR", "HI", "GU")) ``` ] .panel2-wind2-auto[ ``` # A tibble: 57,856 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 57,846 more rows ``` ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% * ggplot() ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_03_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + * aes(x = xlong, y = ylat) ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_04_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + aes(x = xlong, y = ylat) + * borders("state") ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_05_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + aes(x = xlong, y = ylat) + borders("state") + * geom_point(col = "darkred", alpha = .5) ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_06_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "darkred", alpha = .5) + * geom_density_2d(col = "steelblue") ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_07_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "darkred", alpha = .5) + geom_density_2d(col = "steelblue") + * coord_map(projection = "mercator") ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_08_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "darkred", alpha = .5) + geom_density_2d(col = "steelblue") + coord_map(projection = "mercator") + * labs(title = "Wind turbines in the CONUS") ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_09_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table .panel1-wind2-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% ggplot() + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "darkred", alpha = .5) + geom_density_2d(col = "steelblue") + coord_map(projection = "mercator") + labs(title = "Wind turbines in the CONUS") + * theme_void() ``` ] .panel2-wind2-auto[ <img src="lecture-02_files/figure-html/wind2_auto_10_output-1.png" width="432" /> ] <style> .panel1-wind2-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-wind2-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-wind2-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r *us_wind ``` ] .panel2-wind3-auto[ ``` # A tibble: 58,185 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% * filter(!t_state %in% c("AK", "PR", "HI", "GU")) ``` ] .panel2-wind3-auto[ ``` # A tibble: 57,856 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 57,846 more rows ``` ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% * group_by(t_state) ``` ] .panel2-wind3-auto[ ``` # A tibble: 57,856 x 4 # Groups: t_state [41] t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 57,846 more rows ``` ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% * summarise(n = n()) ``` ] .panel2-wind3-auto[ ``` # A tibble: 41 x 2 t_state n <chr> <int> 1 AR 1 2 AZ 144 3 CA 9037 4 CO 2278 5 CT 3 6 DE 1 7 FL 1 8 IA 4280 9 ID 541 10 IL 2602 # … with 31 more rows ``` ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% summarise(n = n()) %>% * ggplot() ``` ] .panel2-wind3-auto[ <img src="lecture-02_files/figure-html/wind3_auto_05_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% summarise(n = n()) %>% ggplot() + * aes(x = reorder(t_state, -n), y = n) ``` ] .panel2-wind3-auto[ <img src="lecture-02_files/figure-html/wind3_auto_06_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% summarise(n = n()) %>% ggplot() + aes(x = reorder(t_state, -n), y = n) + * geom_col() ``` ] .panel2-wind3-auto[ <img src="lecture-02_files/figure-html/wind3_auto_07_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% summarise(n = n()) %>% ggplot() + aes(x = reorder(t_state, -n), y = n) + geom_col() + * labs(title = "Wind turbines By State", * x = "State", * y = "Total Turbines") ``` ] .panel2-wind3-auto[ <img src="lecture-02_files/figure-html/wind3_auto_08_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% summarise(n = n()) %>% ggplot() + aes(x = reorder(t_state, -n), y = n) + geom_col() + labs(title = "Wind turbines By State", x = "State", y = "Total Turbines") + * theme_bw() ``` ] .panel2-wind3-auto[ <img src="lecture-02_files/figure-html/wind3_auto_09_output-1.png" width="432" /> ] --- count: false #Extending the Wind Table... .panel1-wind3-auto[ ```r us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% group_by(t_state) %>% summarise(n = n()) %>% ggplot() + aes(x = reorder(t_state, -n), y = n) + geom_col() + labs(title = "Wind turbines By State", x = "State", y = "Total Turbines") + theme_bw() + * theme(axis.text.x = element_text(angle = 90)) ``` ] .panel2-wind3-auto[ <img src="lecture-02_files/figure-html/wind3_auto_10_output-1.png" width="432" /> ] <style> .panel1-wind3-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-wind3-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-wind3-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r *USAboundaries::us_states(resolution = "low") ``` ] .panel2-wind4-auto[ ``` Simple feature collection with 52 features and 12 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -179.1743 ymin: 17.91377 xmax: 179.7739 ymax: 71.35256 Geodetic CRS: WGS 84 First 10 features: statefp statens affgeoid geoid stusps name lsad aland awater state_name state_abbr jurisdiction_type 1 23 01779787 0400000US23 23 ME Maine 00 79885221885 11748755195 Maine ME state 2 15 01779782 0400000US15 15 HI Hawaii 00 16634100855 11777698394 Hawaii HI state 3 04 01779777 0400000US04 04 AZ Arizona 00 294198560125 1027346486 Arizona AZ state 4 05 00068085 0400000US05 05 AR Arkansas 00 134771517596 2960191698 Arkansas AR state 5 10 01779781 0400000US10 10 DE Delaware 00 5047194742 1398720828 Delaware DE state 6 13 01705317 0400000US13 13 GA Georgia 00 149169848456 4741100880 Georgia GA state 7 27 00662849 0400000US27 27 MN Minnesota 00 206232257655 18929176411 Minnesota MN state 8 02 01785533 0400000US02 02 AK Alaska 00 1477946266785 245390495931 Alaska AK state 9 06 01779778 0400000US06 06 CA California 00 403501101370 20466718403 California CA state 10 11 01702382 0400000US11 11 DC District of Columbia 00 158364992 18633403 District of Columbia DC district geometry 1 MULTIPOLYGON (((-68.92401 4... 2 MULTIPOLYGON (((-156.0497 1... 3 MULTIPOLYGON (((-114.7997 3... 4 MULTIPOLYGON (((-94.61792 3... 5 MULTIPOLYGON (((-75.77379 3... 6 MULTIPOLYGON (((-85.60516 3... 7 MULTIPOLYGON (((-97.22904 4... 8 MULTIPOLYGON (((179.4813 51... 9 MULTIPOLYGON (((-118.594 33... 10 MULTIPOLYGON (((-77.11976 3... ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% * select(state_abbr) ``` ] .panel2-wind4-auto[ ``` Simple feature collection with 52 features and 1 field Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -179.1743 ymin: 17.91377 xmax: 179.7739 ymax: 71.35256 Geodetic CRS: WGS 84 First 10 features: state_abbr geometry 1 ME MULTIPOLYGON (((-68.92401 4... 2 HI MULTIPOLYGON (((-156.0497 1... 3 AZ MULTIPOLYGON (((-114.7997 3... 4 AR MULTIPOLYGON (((-94.61792 3... 5 DE MULTIPOLYGON (((-75.77379 3... 6 GA MULTIPOLYGON (((-85.60516 3... 7 MN MULTIPOLYGON (((-97.22904 4... 8 AK MULTIPOLYGON (((179.4813 51... 9 CA MULTIPOLYGON (((-118.594 33... 10 DC MULTIPOLYGON (((-77.11976 3... ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> * states ``` ] .panel2-wind4-auto[ ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states *us_wind ``` ] .panel2-wind4-auto[ ``` # A tibble: 58,185 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% * filter(!t_state %in% c("AK", "PR", "HI", "GU")) ``` ] .panel2-wind4-auto[ ``` # A tibble: 57,856 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 57,846 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% * select(t_state) ``` ] .panel2-wind4-auto[ ``` # A tibble: 57,856 x 1 t_state <chr> 1 CA 2 CA 3 CA 4 CA 5 CA 6 CA 7 CA 8 CA 9 CA 10 CA # … with 57,846 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% * group_by(t_state) ``` ] .panel2-wind4-auto[ ``` # A tibble: 57,856 x 1 # Groups: t_state [41] t_state <chr> 1 CA 2 CA 3 CA 4 CA 5 CA 6 CA 7 CA 8 CA 9 CA 10 CA # … with 57,846 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% * summarise(n = n()) ``` ] .panel2-wind4-auto[ ``` # A tibble: 41 x 2 t_state n <chr> <int> 1 AR 1 2 AZ 144 3 CA 9037 4 CO 2278 5 CT 3 6 DE 1 7 FL 1 8 IA 4280 9 ID 541 10 IL 2602 # … with 31 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% * inner_join(states, by = c("t_state" = "state_abbr" )) ``` ] .panel2-wind4-auto[ ``` # A tibble: 41 x 3 t_state n geometry <chr> <int> <MULTIPOLYGON [°]> 1 AR 1 (((-94.61792 36.49941, -94.3612 36.4996, -94.07709 36.49898, -93.95919 36.49872, -93... 2 AZ 144 (((-114.7997 32.59362, -114.8094 32.61712, -114.7649 32.64939, -114.7196 32.71876, -... 3 CA 9037 (((-118.594 33.4672, -118.4848 33.48748, -118.3703 33.40928, -118.2863 33.35146, -11... 4 CO 2278 (((-109.06 38.49999, -109.06 38.49999, -109.0515 39.12609, -109.0512 39.36668, -109.... 5 CT 3 (((-73.69594 41.11526, -73.48271 41.21276, -73.55096 41.29542, -73.54415 41.36632, -... 6 DE 1 (((-75.77379 39.7222, -75.75323 39.75799, -75.71706 39.79232, -75.66285 39.82142, -7... 7 FL 1 (((-81.81169 24.56874, -81.75127 24.65352, -81.67234 24.69951, -81.5846 24.7367, -81... 8 IA 4280 (((-96.62187 42.77925, -96.57794 42.82764, -96.53785 42.87847, -96.54047 42.9086, -9... 9 ID 541 (((-117.243 44.39097, -117.2151 44.42716, -117.2259 44.47939, -117.1672 44.52343, -1... 10 IL 2602 (((-91.50617 40.20064, -91.49696 40.2487, -91.49289 40.26992, -91.46966 40.32241, -9... # … with 31 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% * st_as_sf() ``` ] .panel2-wind4-auto[ ``` Simple feature collection with 41 features and 2 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -124.7258 ymin: 24.49813 xmax: -66.9499 ymax: 49.38436 Geodetic CRS: WGS 84 # A tibble: 41 x 3 t_state n geometry <chr> <int> <MULTIPOLYGON [°]> 1 AR 1 (((-94.61792 36.49941, -94.3612 36.4996, -94.07709 36.49898, -93.95919 36.49872, -93... 2 AZ 144 (((-114.7997 32.59362, -114.8094 32.61712, -114.7649 32.64939, -114.7196 32.71876, -... 3 CA 9037 (((-118.594 33.4672, -118.4848 33.48748, -118.3703 33.40928, -118.2863 33.35146, -11... 4 CO 2278 (((-109.06 38.49999, -109.06 38.49999, -109.0515 39.12609, -109.0512 39.36668, -109.... 5 CT 3 (((-73.69594 41.11526, -73.48271 41.21276, -73.55096 41.29542, -73.54415 41.36632, -... 6 DE 1 (((-75.77379 39.7222, -75.75323 39.75799, -75.71706 39.79232, -75.66285 39.82142, -7... 7 FL 1 (((-81.81169 24.56874, -81.75127 24.65352, -81.67234 24.69951, -81.5846 24.7367, -81... 8 IA 4280 (((-96.62187 42.77925, -96.57794 42.82764, -96.53785 42.87847, -96.54047 42.9086, -9... 9 ID 541 (((-117.243 44.39097, -117.2151 44.42716, -117.2259 44.47939, -117.1672 44.52343, -1... 10 IL 2602 (((-91.50617 40.20064, -91.49696 40.2487, -91.49289 40.26992, -91.46966 40.32241, -9... # … with 31 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% * mutate(area = as.numeric(st_area(.) / 1e6), * perArea = n / area) ``` ] .panel2-wind4-auto[ ``` Simple feature collection with 41 features and 4 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -124.7258 ymin: 24.49813 xmax: -66.9499 ymax: 49.38436 Geodetic CRS: WGS 84 # A tibble: 41 x 5 t_state n geometry area perArea * <chr> <int> <MULTIPOLYGON [°]> <dbl> <dbl> 1 AR 1 (((-94.61792 36.49941, -94.3612 36.4996, -94.07709 36.49898, -93.95919 36.49872, -93... 137806. 0.00000726 2 AZ 144 (((-114.7997 32.59362, -114.8094 32.61712, -114.7649 32.64939, -114.7196 32.71876, -... 295306. 0.000488 3 CA 9037 (((-118.594 33.4672, -118.4848 33.48748, -118.3703 33.40928, -118.2863 33.35146, -11... 410346. 0.0220 4 CO 2278 (((-109.06 38.49999, -109.06 38.49999, -109.0515 39.12609, -109.0512 39.36668, -109.... 269359. 0.00846 5 CT 3 (((-73.69594 41.11526, -73.48271 41.21276, -73.55096 41.29542, -73.54415 41.36632, -... 12943. 0.000232 6 DE 1 (((-75.77379 39.7222, -75.75323 39.75799, -75.71706 39.79232, -75.66285 39.82142, -7... 5320. 0.000188 7 FL 1 (((-81.81169 24.56874, -81.75127 24.65352, -81.67234 24.69951, -81.5846 24.7367, -81... 154392. 0.00000648 8 IA 4280 (((-96.62187 42.77925, -96.57794 42.82764, -96.53785 42.87847, -96.54047 42.9086, -9... 145443. 0.0294 9 ID 541 (((-117.243 44.39097, -117.2151 44.42716, -117.2259 44.47939, -117.1672 44.52343, -1... 216234. 0.00250 10 IL 2602 (((-91.50617 40.20064, -91.49696 40.2487, -91.49289 40.26992, -91.46966 40.32241, -9... 145813. 0.0178 # … with 31 more rows ``` ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% mutate(area = as.numeric(st_area(.) / 1e6), perArea = n / area) %>% * ggplot() ``` ] .panel2-wind4-auto[ <img src="lecture-02_files/figure-html/wind4_auto_12_output-1.png" width="432" /> ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% mutate(area = as.numeric(st_area(.) / 1e6), perArea = n / area) %>% ggplot() + * aes(x = reorder(t_state, -perArea), y = perArea) ``` ] .panel2-wind4-auto[ <img src="lecture-02_files/figure-html/wind4_auto_13_output-1.png" width="432" /> ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% mutate(area = as.numeric(st_area(.) / 1e6), perArea = n / area) %>% ggplot() + aes(x = reorder(t_state, -perArea), y = perArea) + * geom_col() ``` ] .panel2-wind4-auto[ <img src="lecture-02_files/figure-html/wind4_auto_14_output-1.png" width="432" /> ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% mutate(area = as.numeric(st_area(.) / 1e6), perArea = n / area) %>% ggplot() + aes(x = reorder(t_state, -perArea), y = perArea) + geom_col() + * labs(title = "Wind turbines per km2 by state", * x = "State", * y = "Turbines per km2") ``` ] .panel2-wind4-auto[ <img src="lecture-02_files/figure-html/wind4_auto_15_output-1.png" width="432" /> ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% mutate(area = as.numeric(st_area(.) / 1e6), perArea = n / area) %>% ggplot() + aes(x = reorder(t_state, -perArea), y = perArea) + geom_col() + labs(title = "Wind turbines per km2 by state", x = "State", y = "Turbines per km2") + * theme_bw() ``` ] .panel2-wind4-auto[ <img src="lecture-02_files/figure-html/wind4_auto_16_output-1.png" width="432" /> ] --- count: false #Geometry + Table... .panel1-wind4-auto[ ```r USAboundaries::us_states(resolution = "low") %>% select(state_abbr) -> states us_wind %>% filter(!t_state %in% c("AK", "PR", "HI", "GU")) %>% select(t_state) %>% group_by(t_state) %>% summarise(n = n()) %>% inner_join(states, by = c("t_state" = "state_abbr" )) %>% st_as_sf() %>% mutate(area = as.numeric(st_area(.) / 1e6), perArea = n / area) %>% ggplot() + aes(x = reorder(t_state, -perArea), y = perArea) + geom_col() + labs(title = "Wind turbines per km2 by state", x = "State", y = "Turbines per km2") + theme_bw() + * theme(axis.text.x = element_text(angle = 90)) ``` ] .panel2-wind4-auto[ <img src="lecture-02_files/figure-html/wind4_auto_17_output-1.png" width="432" /> ] <style> .panel1-wind4-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-wind4-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-wind4-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Predicates and Operations - So far we have operated on a table with boolean conditions (filter, select) -- - We have derived geometry based attributes (distance and area) -- - Spatial predicates are topologically-invariant *binary* spatial relations based on the DE-9IM. For ease of use "named spatial predicates" have been defined for some common relations. -- - Predicates defined with masks of domain {T,F,*} <center> <img src="lec-img/02-jts-predicates.png" width=40%> </center> --- ```r us_wind %>% filter(t_state == "CA") %>% group_by(t_county) %>% tally() %>% slice_max(n, n = 5) ``` ``` # A tibble: 5 x 2 t_county n <chr> <int> 1 Kern County 4564 2 Riverside County 2298 3 Alameda County 1069 4 Solano County 609 5 Merced County 164 ``` ```r county = filter(ca, name == "Kern") ``` --- count: false #Predicates... .panel1-kern-wind-auto[ ```r *us_wind ``` ] .panel2-kern-wind-auto[ ``` # A tibble: 58,185 x 4 t_state t_county xlong ylat <chr> <chr> <dbl> <dbl> 1 CA Kern County -118. 35.1 2 CA Kern County -118. 35.1 3 CA Kern County -118. 35.1 4 CA Kern County -118. 35.1 5 CA Kern County -118. 35.1 6 CA Kern County -118. 35.1 7 CA Kern County -118. 35.1 8 CA Kern County -118. 35.1 9 CA Kern County -118. 35.1 10 CA Kern County -118. 35.1 # … with 58,175 more rows ``` ] --- count: false #Predicates... .panel1-kern-wind-auto[ ```r us_wind %>% * st_as_sf(coords = c("xlong", "ylat"), * crs = 4269) ``` ] .panel2-kern-wind-auto[ ``` Simple feature collection with 58185 features and 2 fields Geometry type: POINT Dimension: XY Bounding box: xmin: -171.7131 ymin: 13.38938 xmax: 144.7227 ymax: 66.8399 Geodetic CRS: NAD83 # A tibble: 58,185 x 3 t_state t_county geometry * <chr> <chr> <POINT [°]> 1 CA Kern County (-118.3607 35.08378) 2 CA Kern County (-118.3612 35.08151) 3 CA Kern County (-118.3604 35.08471) 4 CA Kern County (-118.364 35.07942) 5 CA Kern County (-118.3543 35.08559) 6 CA Kern County (-118.3513 35.0914) 7 CA Kern County (-118.3576 35.08761) 8 CA Kern County (-118.3513 35.0901) 9 CA Kern County (-118.3576 35.08464) 10 CA Kern County (-118.3659 35.07762) # … with 58,175 more rows ``` ] --- count: false #Predicates... .panel1-kern-wind-auto[ ```r us_wind %>% st_as_sf(coords = c("xlong", "ylat"), crs = 4269) %>% * st_filter(county, .predicate = st_intersects) ``` ] .panel2-kern-wind-auto[ ``` Simple feature collection with 4564 features and 2 fields Geometry type: POINT Dimension: XY Bounding box: xmin: -118.4873 ymin: 34.8717 xmax: -118.1553 ymax: 35.7048 Geodetic CRS: NAD83 # A tibble: 4,564 x 3 t_state t_county geometry * <chr> <chr> <POINT [°]> 1 CA Kern County (-118.3607 35.08378) 2 CA Kern County (-118.3612 35.08151) 3 CA Kern County (-118.3604 35.08471) 4 CA Kern County (-118.364 35.07942) 5 CA Kern County (-118.3543 35.08559) 6 CA Kern County (-118.3513 35.0914) 7 CA Kern County (-118.3576 35.08761) 8 CA Kern County (-118.3513 35.0901) 9 CA Kern County (-118.3576 35.08464) 10 CA Kern County (-118.3659 35.07762) # … with 4,554 more rows ``` ] --- count: false #Predicates... .panel1-kern-wind-auto[ ```r us_wind %>% st_as_sf(coords = c("xlong", "ylat"), crs = 4269) %>% st_filter(county, .predicate = st_intersects) %>% * ggplot() ``` ] .panel2-kern-wind-auto[ <img src="lecture-02_files/figure-html/kern-wind_auto_04_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-kern-wind-auto[ ```r us_wind %>% st_as_sf(coords = c("xlong", "ylat"), crs = 4269) %>% st_filter(county, .predicate = st_intersects) %>% ggplot() + * geom_sf(size = .5) ``` ] .panel2-kern-wind-auto[ <img src="lecture-02_files/figure-html/kern-wind_auto_05_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-kern-wind-auto[ ```r us_wind %>% st_as_sf(coords = c("xlong", "ylat"), crs = 4269) %>% st_filter(county, .predicate = st_intersects) %>% ggplot() + geom_sf(size = .5) + * geom_sf(data = county, fill = NA) ``` ] .panel2-kern-wind-auto[ <img src="lecture-02_files/figure-html/kern-wind_auto_06_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-kern-wind-auto[ ```r us_wind %>% st_as_sf(coords = c("xlong", "ylat"), crs = 4269) %>% st_filter(county, .predicate = st_intersects) %>% ggplot() + geom_sf(size = .5) + geom_sf(data = county, fill = NA) + * theme_minimal() ``` ] .panel2-kern-wind-auto[ <img src="lecture-02_files/figure-html/kern-wind_auto_07_output-1.png" width="432" /> ] <style> .panel1-kern-wind-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-kern-wind-auto { color: black; width: 48.5%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-kern-wind-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false # Predicates... .panel1-touch-auto[ ```r *ggplot() ``` ] .panel2-touch-auto[ <img src="lecture-02_files/figure-html/touch_auto_01_output-1.png" width="432" /> ] --- count: false # Predicates... .panel1-touch-auto[ ```r ggplot() + * geom_sf(data = county, * fill = "red") ``` ] .panel2-touch-auto[ <img src="lecture-02_files/figure-html/touch_auto_02_output-1.png" width="432" /> ] --- count: false # Predicates... .panel1-touch-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + * geom_sf(data = st_filter(ca, county, * .predicate = st_touches), * fill = "blue") ``` ] .panel2-touch-auto[ <img src="lecture-02_files/figure-html/touch_auto_03_output-1.png" width="432" /> ] --- count: false # Predicates... .panel1-touch-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + geom_sf(data = st_filter(ca, county, .predicate = st_touches), fill = "blue") + * theme_bw() ``` ] .panel2-touch-auto[ <img src="lecture-02_files/figure-html/touch_auto_04_output-1.png" width="432" /> ] <style> .panel1-touch-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-touch-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-touch-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false #Predicates... .panel1-within-auto[ ```r *ggplot() ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_01_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-within-auto[ ```r ggplot() + * geom_sf(data = county, fill = "red") ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_02_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-within-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + * geom_sf(data = st_filter(ca, county, .predicate = * st_is_within_distance, dist =6e5), * fill = "orange") ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_03_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-within-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e5), fill = "orange") + * geom_sf(data = st_filter(ca, county, .predicate = * st_is_within_distance, dist =6e4), * fill = "green") ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_04_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-within-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e5), fill = "orange") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e4), fill = "green") + * geom_sf(data = st_filter(ca, county,.predicate = * st_is_within_distance, dist =6e3), * fill = "blue") ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_05_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-within-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e5), fill = "orange") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e4), fill = "green") + geom_sf(data = st_filter(ca, county,.predicate = st_is_within_distance, dist =6e3), fill = "blue") + * geom_sf(data = county, * fill = "red") ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_06_output-1.png" width="432" /> ] --- count: false #Predicates... .panel1-within-auto[ ```r ggplot() + geom_sf(data = county, fill = "red") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e5), fill = "orange") + geom_sf(data = st_filter(ca, county, .predicate = st_is_within_distance, dist =6e4), fill = "green") + geom_sf(data = st_filter(ca, county,.predicate = st_is_within_distance, dist =6e3), fill = "blue") + geom_sf(data = county, fill = "red") + * theme_bw() ``` ] .panel2-within-auto[ <img src="lecture-02_files/figure-html/within_auto_07_output-1.png" width="432" /> ] <style> .panel1-within-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-within-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-within-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- ## Data science is script driven - You use an IDE / Command Line - Data is left raw and manipulated with scripts - Scripts are shareable, reproducible, and self-contained - Scripts are process documenting <img src="lec-img/02-r-studio-ide.png" width="50%"> --- class: center, middle, inverse # What is the Alternative?? --- ## GISystems: the shapefile view A geographic information system (GIS) is a framework for gathering, managing, and analyzing data. - It is limited to spatial data (table manipulation is minimal) - Operates on its own information system (.shp is a data single) - Is driven through user interaction with clicks and text entries --- ### ... shapefiles have at minimum 4 components .pull-left[ - Geometry (.shp) - Data (.dbf) - Relations (.shx) - Projection (.prj) (will discuss soon...) all stored separately... - a shapefile is data model of a data model (sf geometry) ] .pull-right[ <img src="lec-img/02-shp-model.png" width="378" /> ] --- ## ... point-and-click UI - Geometries (shp) are rendered and symbolized by a data field (dbf) in graphical interfaces - there is no way to record what clicks you make, or what order they are made in... <center> <img src="lec-img/02-qgis.png" width="50%"> </center> --- ### Both the data science and GISystem approach make use of tables and geometries: - Data Science approach treats geometry as a **column** of the table - Allows single file storage, and operations directly on the data AND on the geometry - GISystem (shapefile) approach requires a multi-file approach - associates a table **dbf** file with a geometry **shp** file using an **shx** file ### In both cases coordinates - composite geometries - must have a <span class="code">reference system</span> --- # Wait! What about Raster (Feild) Data?? - Raster are another type of data structure (array) ```r x = system.file("tif/L7_ETMs.tif", package = "stars") %>% raster::brick() ``` --- ```r par(mfrow = c(1,3), mar = c(0,0,0,0)) plotRGB(x, 4,3,2, main = "Color Infared") plotRGB(x, 3,2,1, main = "Natural Color") plotRGB(x, 5,4,3, main = "Psuedo color") ``` <img src="lecture-02_files/figure-html/unnamed-chunk-19-1.png" width="432" style="display: block; margin: auto;" /> --- # Time Slices ... ```r AOI = AOI::aoi_get(state = "NC") ppt = climateR::getGridMET(AOI, param = "prcp", startDate = "2018-09-12", endDate = "2018-09-17") plot(ppt$prcp) ``` <img src="lecture-02_files/figure-html/hurricane-1.png" width="432" /> --- # Across time ... <img src="lec-img/02-hurricane.gif" height="95%"> --- count: false #Object/Field Interaction... .panel1-hurricane2-auto[ ```r *library(exactextractr) ``` ] .panel2-hurricane2-auto[ ] --- count: false #Object/Field Interaction... .panel1-hurricane2-auto[ ```r library(exactextractr) *counties = AOI::aoi_get(state = "NC", * county = 'all') ``` ] .panel2-hurricane2-auto[ ] --- count: false #Object/Field Interaction... .panel1-hurricane2-auto[ ```r library(exactextractr) counties = AOI::aoi_get(state = "NC", county = 'all') *means = cbind(counties, * exact_extract(ppt$prcp, * counties, * "mean", * progress = F)) ``` ] .panel2-hurricane2-auto[ ] --- count: false #Object/Field Interaction... .panel1-hurricane2-auto[ ```r library(exactextractr) counties = AOI::aoi_get(state = "NC", county = 'all') means = cbind(counties, exact_extract(ppt$prcp, counties, "mean", progress = F)) *plot(means['mean.X2018.09.15']) ``` ] .panel2-hurricane2-auto[ <img src="lecture-02_files/figure-html/hurricane2_auto_04_output-1.png" width="432" /> ] --- count: false #Object/Field Interaction... .panel1-hurricane2-auto[ ```r library(exactextractr) counties = AOI::aoi_get(state = "NC", county = 'all') means = cbind(counties, exact_extract(ppt$prcp, counties, "mean", progress = F)) plot(means['mean.X2018.09.15']) ``` ] .panel2-hurricane2-auto[ <img src="lecture-02_files/figure-html/hurricane2_auto_05_output-1.png" width="432" /> ] <style> .panel1-hurricane2-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-hurricane2-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-hurricane2-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false #Total Rainfall... .panel1-hurricane3-auto[ ```r *means = means ``` ] .panel2-hurricane3-auto[ ] --- count: false #Total Rainfall... .panel1-hurricane3-auto[ ```r means = means %>% * mutate(total_rainfall = * rowSums(select(st_drop_geometry(means), * starts_with("mean.X")))) ``` ] .panel2-hurricane3-auto[ ] --- count: false #Total Rainfall... .panel1-hurricane3-auto[ ```r means = means %>% mutate(total_rainfall = rowSums(select(st_drop_geometry(means), starts_with("mean.X")))) *plot(means['total_rainfall']) ``` ] .panel2-hurricane3-auto[ <img src="lecture-02_files/figure-html/hurricane3_auto_03_output-1.png" width="432" /> ] <style> .panel1-hurricane3-auto { color: black; width: 38.8%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-hurricane3-auto { color: black; width: 58.2%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-hurricane3-auto { color: black; width: 0%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Today... - New Storm -- - New State(s) -- - same analysis ... -- <img src="lec-img/02-isaias-track.png"> --- class: center, middle <iframe width="750" height="600" src="https://www.youtube.com/embed/s3JldKoA0zw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> --- In many ways, the benefits of using R over a desktop GIS are similar to the benefits of using R over Excel for data analysis. - R is free and open source, not limited to university or employer licenses - As a full-fledged programming language, you have greater flexibility than the point-and-click interface of a desktop GIS or a dedicated language like arcpy. - Analysis are self documenting and reproducible - There is a large community of developers working on spatial workflows, design and implementation --- ## Summary - GIS is an "awkward" combination of information and data science that involves a unique type of data (coordinates with spatial reference) - Thus the confusion around what is "GIS" - Events and characteristics are continuous in space and time and are discretized by human imposed units. These discrete units are stored as tables. - spatial data can be seen as *tables*, _extended_ with geometries. - tables can be evaluated with core data science practices, - geometries can be analyized with existing geometric practices. - In order to best leverage spatial data there is a strong advantage in being fluent in working with the table and geometry and working within a system in which these can be - for DS, many new operators become available (predicates, measures, intersection/buffer/union) Such a view gives us the advantages of the attribute AND the spatial components - geometry sets, with attributes in tables (GIS view) --- # Coming soon ...
- Tomorrow - Naming things, building projects, data types -- - Thursday - Data Structures & Indexing (1D, 2D, 3D, ...) -- - Week 2: Working with Tables -- - Week 3-4: Working with Geometry -- - Week 5-6: Working with Arrays (Fields) -- # Assignment: [Set up Git and Github](assignment-02.html) --- class: middle, center # END