50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

ggmap (version 1.2)

ggmap: Grab a map.

Description

ggmap is a smart function which queries the Google Maps server or OpenStreetMap server for a map at a certain location at a certain spatial zoom.

Usage

ggmap(location = "houston", lonR, latR,
    center = c(lat = 29.7632836, lon = -95.3632715),
    regularize = TRUE, type = c("color", "bw"),
    rgbcoefs = c(0, 1, 0), zoom = 10, maptype = "terrain",
    source = c("google", "osm"), verbose = FALSE,
    destfile = "ggmapTemp.jpg", n_pix = 640,
    scale = OSM_scale_lookup(zoom), raster = TRUE, ...)

Arguments

location
a character string containing the name of the location of interest
lonR
longitude range (only for OpenStreetMaps)
latR
latitude range (only for OpenStreetMaps)
center
named numeric vector of latitude and longitude specifying the center of the image
regularize
logical; should the map grid be regularized?
type
'color' for a color map, 'bw' for a black and white map
rgbcoefs
when 'bw' is specified, conversions coefficients to use. see ?ReadImages::rgb2grey
zoom
level of zoom, an integer 0 (whole world) to 19 (higest zoom), default value 10
maptype
any of 'roadmap', 'mobile', 'satellite', 'terrain', 'hybrid', 'mapmaker-roadmap', 'mapmaker-hybrid'
source
'google' or 'osm' (OpenStreetMaps)
verbose
logical; should function message user?
destfile
character; name of file to save downloaded map
n_pix
numeric; number of pixels in map
scale
numeric; scale of OpenStreetMap, see ?GetMap
raster
logical; use geom_raster?
...
...

Value

  • a data.frame with columns latitude, longitude, and fill

See Also

ggmapplot, GetMap in package RgoogleMaps

Examples

Run this code
WashingtonMap_df <- ggmap(location = 'washington', verbose = TRUE)
str(WashingtonMap_df)
ggmapplot(WashingtonMap_df)

lonR <- c(-97.12008, -97.11836)
latR <- c(31.54765, 31.54911)
osm <- ggmap(latR = latR, lonR = lonR, source = 'osm', scale = 1000)
ggmapplot(osm)

Run the code above in your browser using DataLab