Why is my ggplot2 map misreading input latitude and longitude data?

53 Views Asked by At

I am trying to add city points and labels to a ggplot2 map, and when I add a geom_point() layer to the map with a specified points drawn from a newly created dataframe with specified latitude and longitude, it outputs points and labels at different latitudes and longitudes than the ones specified. This is the code, and when the map outputs the points are at lat: 26.00 and long:33.00, and the map is distorted. When I take off the geom_point() and geom_text layers the scale of the map returns to what it should be. distorted map output

city_data <- data.frame(city_name=c("Beit Hanina"))
city_data$lat <- c(31.8400)
city_data$lon <- c(35.2200)

ggplot(data = ejru) + 
  geom_sf()+
  geom_point(data = city_data, mapping = aes(x = lon, y = lat), colour = "red") +
  geom_text(data = city_data, mapping=aes(x=lon, y=lat, label=city_name), nudge_y = 0.5,           color="darkblue")

I have tried several different strings of code to add points, and either the points simply don't show up or they are distorted as they are in this case.

0

There are 0 best solutions below