My dataset is a geodatabase with Oregon Data. I used it in a previous GIS class. It includes 14 layers: airports, highways, railroads, water bodies, rivers, cities, counties, hospitals, major cities, parks, schools, state boundary, tracts, and volcanoes. The layers have different geometry types, features, and fields.
library(sf)
## Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
oregon <- st_read("oregondata.gdb")
## Multiple layers are present in data source /Users/devinhainje/Desktop/R/oregondata.gdb, reading layer `airports'.
## Use `st_layers' to list all layer names and their type in a data source.
## Set the `layer' argument in `st_read' to read a particular layer.
## Warning in evalq((function (..., call. = TRUE, immediate. = FALSE, noBreaks. =
## FALSE, : automatically selected the first layer in a data source containing more
## than one.
## Reading layer `airports' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 9 features and 8 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: 96760.55 ymin: 45902.32 xmax: 529171.4 ymax: 495156.4
## projected CRS: NAD83 / Oregon LCC (m)
#Step 1 The first step is to use st_read to bring in “oregondata.gdb”
#Step 2 The second step is to use st_layers to read all the layers in the geodatabase. “oregondata.gdb” contains 14 layers. They are all character data apart of oregon_layers
oregon_layers <- st_layers(dsn = "oregondata.gdb")
oregon_layers
## Driver: OpenFileGDB
## Available layers:
## layer_name geometry_type features fields
## 1 airports Point 9 8
## 2 highways Multi Line String 1958 10
## 3 rail100k Multi Line String 1834 10
## 4 waterbodies Multi Polygon 157 6
## 5 rivers Multi Line String 746 5
## 6 cities Point 283 8
## 7 counties Multi Polygon 36 51
## 8 hospitals Point 58 4
## 9 majcities Point 49 46
## 10 parks Multi Polygon 362 5
## 11 schools Point 1336 4
## 12 statedtl Multi Polygon 1 50
## 13 tracts Multi Polygon 755 47
## 14 volcanoes Point 20 8
state <- st_read("oregondata.gdb", layer = "statedtl")
## Reading layer `statedtl' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 1 feature and 50 fields
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: 67606.12 ymin: 27015.75 xmax: 714797.9 ymax: 511310.1
## projected CRS: NAD83 / Oregon LCC (m)
plot(state)
## Warning: plotting the first 9 out of 50 attributes; use max.plot = 50 to plot
## all
#Step 3 The third step is to use st_read to create a new variable for each needed layer. I brought in the state, counties, rivers, cities, volcanoes, and hospitals. The rivers object has 6 columns: Feature (character), Name (charcter), State (character), Miles (numeric), Shape Length (numeric), and Shape (sfc_MULTILINESTRING)
counties <- st_read("oregondata.gdb", "counties")
## Reading layer `counties' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 36 features and 51 fields
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: 68189.83 ymin: 26484.53 xmax: 714238.5 ymax: 502749.3
## projected CRS: NAD83 / Oregon LCC (m)
rivers <- st_read("oregondata.gdb", "rivers")
## Reading layer `rivers' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 746 features and 5 fields
## geometry type: MULTILINESTRING
## dimension: XY
## bbox: xmin: 69998.18 ymin: 27499.33 xmax: 714776.5 ymax: 495546.4
## projected CRS: NAD83 / Oregon LCC (m)
cities <- st_read("oregondata.gdb", "cities")
## Reading layer `cities' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 283 features and 8 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: 72808.39 ymin: 29608.31 xmax: 683415.4 ymax: 498330.6
## projected CRS: NAD83 / Oregon LCC (m)
volcanoes <- st_read("oregondata.gdb", "volcanoes")
## Reading layer `volcanoes' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 20 features and 8 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: 267665.4 ymin: 99366.17 xmax: 646318 ymax: 403298.8
## projected CRS: NAD83 / Oregon LCC (m)
hospitals <- st_read("oregondata.gdb", "hospitals")
## Reading layer `hospitals' from data source `/Users/devinhainje/Desktop/R/oregondata.gdb' using driver `OpenFileGDB'
## Simple feature collection with 58 features and 4 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: 98339.75 ymin: 53146.28 xmax: 682285.8 ymax: 498319.6
## projected CRS: NAD_1983_CORS96_Oregon_Statewide_Lambert
str(rivers)
## Classes 'sf' and 'data.frame': 746 obs. of 6 variables:
## $ FEATURE : chr "Stream" "Stream" "Stream" "Stream" ...
## $ NAME : chr "Beaver Creek" "Grande Ronde River" "Youngs River" "Mill Creek" ...
## $ STATE : chr "OR" "WA" "OR" "OR" ...
## $ MILES : num 25.15 31.02 14.13 5.18 3.96 ...
## $ Shape_Length: num 40425.1 67.1 22806.7 7970.5 6118.9 ...
## $ Shape :sfc_MULTILINESTRING of length 746; first list element: List of 1
## ..$ : num [1:97, 1:2] 192537 192620 192891 192941 193192 ...
## ..- attr(*, "class")= chr [1:3] "XY" "MULTILINESTRING" "sfg"
## - attr(*, "sf_column")= chr "Shape"
## - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA
## ..- attr(*, "names")= chr [1:5] "FEATURE" "NAME" "STATE" "MILES" ...
Now the data can be plotted and manipulated to the users needs.