Turning Data Frames Into sf Objects
This lesson is called Turning Data Frames Into sf Objects, part of the Mapping with R course. This lesson is called Turning Data Frames Into sf Objects, part of the Mapping with R course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
View code shown in video
library(tidyverse)
library(sf)
portland_corners_csv <-
read_csv("https://raw.githubusercontent.com/rfortherestofus/mapping-with-r-v2/refs/heads/main/data/portland_corners.csv")
portland_corners_csv
portland_corners_sf <-
portland_corners_csv |>
st_as_sf(
coords = c("longitude", "latitude"),
crs = 4326
)
portland_corners_sf |>
mapview::mapview()
Your Turn
Download this CSV of traffic signal data for the city of Portland
Import the CSV and turn it into an
sf
object usingst_as_sf()
Run
mapview::mapview()
to ensure you imported it correctly
Learn More
Chapter 3 of the book Spatial Statistics for Data Science: Theory and Practice with R covers turning data frames into sf objects.
Have any questions? Put them below and we will help you out!
Course Content
23 Lessons
You need to be signed-in to comment on this post. Login.