## Example 1
## quickMap code
## as example of third-party use of functions
quickMap <- function(lat, lon, show.data = FALSE, ...){
#get map
map <- getRGMapArg(lat, lon, ...)
#scale axis for map projection
map.axis.comps <- axis.components.loaMap(map)
map.axis <- function(components, ...)
axis.default(components = map.axis.comps, ...)
#scale data for map projection
temp <- LatLon2MercaptorXY(lat, lon)
lat <- temp$newY
lon <- temp$newX
#plot data on map
xyplot(lat~lon,
xlim = map$xlim, ylim = map$ylim,
aspect = map$aspect,
axis = map.axis,
panel = function(...){
panel.loaGBMapPlotRaster(map)
if(show.data)
panel.xyplot(...)
}, ...)
}
## Example 2
## Off-line loaMapPlot example:
loaMapPlot(zinc~latitude*longitude, col.regions=c("grey", "darkred"),
data=lat.lon.meuse, map=roadmap.meuse)
# Note 1:
# Here, the map argument is supplied so example works off-line.
# If not supplied and R is on-line, the MapPlots will get map
# from either Google or OpenStreetMap API. Repeat any of above
# without map argument when on-line. For example:
if (FALSE) {
loaMapPlot(zinc~latitude*longitude, col.regions=c("grey", "darkred"),
data=lat.lon.meuse)}
# (The map will appear slightly different because non-default
# size and maptype settings were used to make roadmap.meuse. See
# ?roadmap.meuse for details.)
# Note 2:
# To make a map for use with panel.loaBGMapPlotRaster or panel.loaBGMapPlotRaster
# without plotting use makeRGMapArg() or makeOSMapArg().
# To recover a map from a previously plotted loa MapPloy use loaMapArg().
# Note 3:
# Other example loaMapPlots (also not run):
# using panel.binPlot to change data layer
if (FALSE) {
loaMapPlot(zinc~latitude*longitude, col.regions=c("grey", "darkred"),
panel=panel.binPlot, data=lat.lon.meuse)}
# using zcase panelling to handle multiple z terms
if (FALSE) {
loaMapPlot(cadmium*50+copper*10+lead*2+zinc~latitude*longitude,
col.regions=c("grey", "darkred"), key.z.main="Concentrations",
panel.zcases = TRUE, data=lat.lon.meuse)}
# using a specialist panel to handle multiple z terms
# (Please note: This will take a while...)
if (FALSE) {
loaMapPlot(cadmium*50+copper*10+lead*2+zinc~latitude*longitude,
col.regions=c("grey", "darkred"), panel=panel.zcasePiePlot,
data=lat.lon.meuse)}
# Note 4:
# For all maps generated in above examples, the Map layer is
# (c) OpenStreetMap contributors
Run the code above in your browser using DataLab