1

I am using a macOS Big Sur

This is the simple code I am using- regardless of the city I only get one point in the map, centered around Nebraska.

library(maps)
library(ggmap)
library(usmap)
library(ggplot2)

GeoLocations <- data.frame(City = c("Atlanta","Seattle"),
                           Latitude = c(33.45,47.37),
                           Longitude = c(-84.23,-122.2))
plot_usmap(regions ="state") +
  geom_point(data = GeoLocations, aes(x = Longitude, y = Latitude))

Help is much appreciated

Manuel
  • 21
  • 2

2 Answers2

1

usmap package requires an other coordinate system that is different from yours (it is already explained here : Add points to usmap with ggplot in r)

To solve this you need :

GeoLocations <- data.frame(Longitude = c(-84.23,-122.2),
                           Latitude = c(33.45,47.37)) #keeping only Longitude and Latitude columns
GeoLocations <- usmap_transform(GeoLocations) #transform coordinates
plot_usmap(regions ="state") + geom_point(data = GeoLocations, aes(x = Longitude.1, y = Latitude.1))
Basti
  • 1,703
  • 3
  • 10
  • 25
0

To expand @BastienDucreux's answer, you can also help ggplot to recognize the coordinate reference system and then use the ggspatial package to plot the points.

library(ggspatial)

plot_usmap(regions ="state") +
  coord_sf(crs = usmap::usmap_crs()) +
  ggspatial::geom_spatial_point(data = GeoLocations,
                                aes(x = Longitude, y = Latitude), crs = 4326) 

enter image description here

Mikko
  • 7,530
  • 8
  • 55
  • 92