Learn R Programming

RgoogleMaps (version 1.1.9.3)

PlotOnStaticMap: overlays plot on background image of map tile

Description

This function is the workhorse of the package RgoogleMaps. It

Usage

PlotOnStaticMap(MyMap, lat, lon, destfile, zoom=NULL, size = c(640,640), GRAYSCALE  = FALSE, 
               add=FALSE, FUN = points, mar=c(0,0,0,0), NEWMAP = TRUE, TrueProj = TRUE, axes= FALSE, verbose = 1,...)

Arguments

MyMap
optional map object to be passed
lat
vector latitude values to be overlaid
lon
vector of longitude values to be overlaid
destfile
File to load the map image from or save to, depending on whether MyMap was passed.
zoom
Google maps zoom level. optional if MyMap is passed, required if not.
size
desired size of the map tile image. defaults to maximum size returned by the Gogle server, which is $640x640$ pixels.
GRAYSCALE
Boolean toggle; if TRUE the colored map tile is rendered into a black & white image, see RGB2GRAY
add
start a new plot or add to an existing
FUN
plotting function to use for overlay; typical choices would be points and lines
mar
outer margin in plot; if you want to see axes, change the default
NEWMAP
load map from file or get it "new" from the static map server
TrueProj
set to FALSE if you are willing to accept some degree of inaccuracy in the mapping. In that case, the coordinates of the image are in lat/lon and the user can simply overly points/lines/axis without worrying about projections
axes
overlay axes ? Note that if the package sp is installed, those axis will show labels in degrees.
verbose
level of verbosity
...
further arguments to be passed to FUN

Value

  • the map object is returned via invisible(MyMap)

Details

NOte: To handle png file formats, you will need the package rgdal installed, for jpeg the package ReadImages.

See Also

GetMap GetMap.bbox

Examples

Run this code
#The first step naturally will be to download a static map from the Google server. A simple example:

  MyMap <- GetMap(markers = '40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc', destfile = "MyTile1.png");
                 
   tmp <- PlotOnStaticMap(MyMap, lat = c(40.702147,40.711614,40.718217), lon = c(-74.015794,-74.012318,-73.998284), destfile = "MyTile1.png", cex=1.5,pch=20,col=c('red', 'blue', 'green'), add=F);
   	#and add lines:
   	PlotOnStaticMap(MyMap, lat = c(40.702147,40.711614,40.718217), lon = c(-74.015794,-74.012318,-73.998284), lwd=1.5,col=c('red', 'blue', 'green'), FUN = lines, add=T)

Run the code above in your browser using DataLab