Extract Maps Using GGMAP
Step 1: Install and Load Required Package
>install.packages("ggmap", type = "source")>library(ggmap)
Step 2: Define Latitude and Longitude
>lat <- c(6.7535159,35.5087008)>lon <- c(68.1623859,97.395561)
Step 3: Extract Map
>india_Map <- get_map(location = c(lon=mean(lon), lat=mean(lat)), zoom = 5, maptype = "terrain", source = "google")>ggmap(india_Map)
Output:
Use different map types as per your preference
>india_Map <- get_map(location = c(lon=mean(lon), lat=mean(lat)), zoom = 4, maptype = "hybrid", source = "google")
>ggmap(india_Map)
>india_Map <- get_map(location = c(lon=mean(lon), lat=mean(lat)), zoom = 4, maptype = "hybrid", source = "google")
>ggmap(india_Map)
Output:
>india_Map <- get_map(location = c(lon=mean(lon), lat=mean(lat)), zoom = 5, force = ifelse(source == "google", TRUE, TRUE), maptype = "satellite", source = "google")
>ggmap(india_map)























