Reputation: 305
I am marking some points on a UAE map. I am using ggmap and ggplot2 packages for the purpose.
my code for plotting and marking the map is:
library(ggmap)
library(ggplot2)
d <- data.frame(lat=c(24.534505, 24.529291,24.529291, 24.543425, 24.551134, 24.555446, 24.560406, 24.558412, 24.558670, 24.548625, 24.547120, 24.540850, 24.540428, 24.534505),lon=c(55.415467, 55.419130, 55.432415, 55.465657, 55.462406, 55.473639, 55.471087, 55.465286, 55.465211, 55.438385, 55.439173, 55.427146, 55.427119, 55.415467))
map <- get_map("Sweihan, United Arab Emirates", zoom = 11, maptype = "satellite", source = "google")
Sweihan <- ggmap(map)+geom_point(data = d, aes(x = lon, y = lat))+geom_path(data = d, aes(x = lon, y = lat))+scale_x_continuous(limits = c(55.41, 55.48)) +
scale_y_continuous(limits = c(24.52, 24.5655))
Sweihan
Now the thing is after running this code, I am being able to get correct map and exact points that I wanted to plot. But I am not being about to get the clarity of map. I have tried zoom in get_map function, that isn't helping. Is there any approach that I can use within my code to get a visible map.
Any help will be appreciated!
Thanks in Advance!
Upvotes: 0
Views: 107
Reputation: 9923
Finding the map by address is convenient, but there is more control if you use the longitude/latitude
map <- get_map(location = c(mean(d$lon), mean(d$lat)), zoom = 13, maptype = "satellite", source = "google")
ggmap(map)+
geom_point(data = d, aes(x = lon, y = lat))+
geom_path(data = d, aes(x = lon, y = lat))
ggmap has already set the x and y scales, so you will get warnings if you try to replace them.
Upvotes: 1