-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslides-accessing-raw-geospatial-data.qmd
97 lines (55 loc) · 2.86 KB
/
slides-accessing-raw-geospatial-data.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
title: Accessing Raw Geospatial Data
---
### {sf} Package
![](assets/sf.png)
### Geospatial Data Formats: ESRI Shapefile {.inverse}
### ESRI Shapefile
Consists of multiple files:
1. `.shp`: The main file that contains the geometry data (shapes) of the features.
1. `.shx`: The shape index file, which stores the positional index of the feature geometry to improve access speed.
1. `.dbf`: The attribute format file, which stores attribute data in a tabular format. This file uses the dBase format.
### ESRI Shapefile
In addition to these three mandatory files, there are several optional files that can accompany a shapefile:
- `.prj`: The projection file, which contains coordinate system and projection information.
- `.sbn` and `.sbx`: Spatial index files that improve the speed of spatial queries.
- `.fbn` and `.fbx`: Files used for spatial indexing of features that have been deleted.
### ESRI Shapefile
- `.ain` and `.aih`: Attribute index files that improve the speed of attribute queries.
- `.ixs` and `.mxs`: Geocoding index for read-write and read-only datasets, respectively.
- `.cpg`: The code page file, which specifies the character encoding used in the .dbf file.
### ESRI Shapefile
- [Import city council data from PortlandMaps Open Data](https://gis-pdx.opendata.arcgis.com/datasets/2aec1ba28a6d47b790d59dd831f9bc76_1413/explore?location=45.485228%2C-122.289380%2C9.18)
- Import data with `read_sf()`
---
```{r}
library(sf)
read_sf("data/Portland_City_Council_Districts.shp")
```
---
TODO: center slide
[![](assets/shapefile-airplane-meme.jpg)](https://www.reddit.com/r/gis/comments/sbp8r9/please_find_the_shapefile_attached/)
---
```{r}
read_sf("data/Portland_City_Council_Districts.shp")
```
### Geospatial Data Formats: GeoJSON {.inverse}
### Geospatial Data Formats: GeoJSON
- One file with everything you need embedded within it
- [Import GeoJSON city council data from PortlandMaps Open Data](https://gis-pdx.opendata.arcgis.com/datasets/2aec1ba28a6d47b790d59dd831f9bc76_1413/explore?location=45.485228%2C-122.289380%2C9.18)
---
```{r}
read_sf("data/Portland_City_Council_Districts.geojson")
```
### Geospatial Data Formats: Others {.inverse}
---
TODO: center slide
[![](assets/geospatial-data-formats.png)](https://r.geocompx.org/read-write)
### Geospatial Data Formats: Others
- Almost all file formats can be imported with `read_sf()`
### Your Turn {.your-turn}
- [Download data (ESRI Shapefile or GeoJSON) on Portland sextants](https://gis-pdx.opendata.arcgis.com/datasets/PDX::portland-administrative-sextants/explore)
- Import the data in R using the `read_sf()` function from the `sf` package and save it as `portland_sextants`
- Examine `portland_sextants`, making sure you can identify its geometry type, dimensions, bounding box, coordinate reference system and `geometry` column
### Learn More
https://r-spatial.github.io/sf/articles/sf2.html