Reputation: 45
I'm trying to map crime incidents in Boston. I converted the lat/long to simple feature points but when I plotted it, I only got two points. Does anyone know how to remedy this?
crimedata = read.csv("2019 Crime Incidents.csv", stringsAsFactors = FALSE)
points = st_as_sf(crimedata, coords = c("Lat", "Long"), crs = 4326)
plot(points$geometry, pch=16, col="navy")
Upvotes: 0
Views: 611
Reputation: 10627
You need to plot the points on top of a map:
library(tidyverse)
library(ggmap)
points <- tibble(
lon = c(-100, -90),
lat = c(40, 40),
value = c("A", "B")
)
c(left = -125, bottom = 25.75, right = -67, top = 49) %>%
get_stamenmap(zoom = 5, maptype = "toner-lite") %>%
ggmap() +
geom_point(
data = points,
mapping = aes(color = value),
size = 7
)
Upvotes: 1