I'm new to R. i want to generate a heat map using PHP, MongoDB and R. i want to plot geo coordinates(Lat, Lng) on World Map. Below is the sample code i'm trying to use. please let me know how to plot 4 million of lat and lng points on static map.
# loading the required packages
require(ggplot2)
require(ggmap)
# creating a sample data.frame with your lat/lon points
lon <- c(78.381270, 78.136352, 77.179950)
lat <- c(17.440229, 10.104529, 28.680417)
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 4,
maptype = "roadmap", scale = 2)
# plotting the map with some points on it
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size = 3, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)
Please provide me the appropriate solution. Thanks In advance.