osmMap: Create an OpenStreetMap view of Spatial Data

Description Usage Arguments Details Value Author(s) Examples

View source: R/osmMap.R

Description

Take some sp-class objects (SpatialPointsDataFrame, SpatialPolygonsDataFrame etc) and create an OpenLayers map using OpenStreetMap background data.

Usage

1
osmMap(..., title = "map", outputDir = tempdir(), htmlFile = "index.html", browse = FALSE)

Arguments

...

Some layer objects

title

The map title.

outputDir

Where to put the html and data files.

htmlFile

The name of the html file.

browse

If TRUE, open R's default web browser on completion.

Details

All spatial data must be in EPSG:4326 coordinates - this is also WGS84, and is the most common lat-long system used by GPS and other web mapping systems.

Value

The path to the HTML file. Open this in your favourite browser. You need a browser with good JavaScript and SVG support.

Author(s)

Barry Rowlingson

Examples

1
2
3
4
5
6
7
8
9
# create a spatial points data frame from the state data:
statesp = data.frame(state.x77)
statesp$Name = row.names(statesp)
coordinates(statesp) = cbind(state.center$x,state.center$y)
# how to produce three layers:
osmMap(layer(statesp[state.center$x < -109,],name="state1",lstyle(fillColor="red")),
       layer(statesp[state.center$x >= -109 & state.center$x < -84,],
             name="state2",lstyle(fillColor="blue",fillOpacity=0.5)),
       layer(statesp[state.center$x > -84,],name="state3"))

webmaps documentation built on May 2, 2019, 4:52 p.m.