Visualizing Geospatial Data in R
Charlotte Wickham
Assistant Professor at Oregon State University
head(sales)
lon lat price bedrooms baths
1 -123.2803 44.57808 267500 5 2
2 -123.2330 44.59718 255000 3 2
3 -123.2635 44.56923 295000 3 2
4 -123.2599 44.59453 5000 0 1
5 -123.2632 44.53606 13950 0 2
6 -123.2847 44.59877 233000 3 2
nrow(sales)
931
library(ggplot2)
ggplot(sales, aes(lon, lat)) + geom_point()
library(ggmap)
# Coordinates for location of interest nyc <- c(lon = -74.0059, lat = 40.7128)
# 1. Download the relevant map nyc_map <- get_map(location = nyc, zoom = 10)
# 2. Display the map ggmap(nyc_map)
Visualizing Geospatial Data in R