
openmap
function in the openmap packageopenmap(x, zoom,
path="http://tile.openstreetmap.org/",
maxTiles = 9,
crs, cacheDir=tempdir(), verbose=FALSE)
getTiles(xlim,ylim,zoom,path,maxTiles = 16,cacheDir=tempdir(),
timeOut=5*24*60*60,verbose=FALSE)
x
. If x
has no projection,
for instance when x
is a matrix or extent,
crs
is also used as the projection of x
. If cr
openmap
returns a RasterBrick
brick
, with 'red', 'green' and 'blue' layers. getTiles
returns a list
of RasterBricksMap tiles are a set of PNG images that span the world at a set of zoom levels. Zoom level 0 has one tile that covers the whole world at a resolution of 256x256 pixels. Zoom level 1 has four 256x256 pixel tiles in a 2x2 pattern over the whole world. In general, zoom level n has 2^n by 2^n tiles. Zoom levels go up to about 17 or 18 depending on the tile server.
The function getTiles() retrieves tiles to cover a given latitude and longitude range at a given zoom level. Note that since tiles are generated at a fixed set of lat-long ranges the returned tiles will overlap the requested area. There may be some way of clipping to the requested area in a future revision.
The getTilePaths() function returns information about tiles in a region at a zoom level. The tile source path is given but tiles are not requested. A list is returned with one element per tile giving the path, the I and J coordinates, the zoom level, and the geographic bounds for the tile.
The tileBbox() function returns the bounds of the tiles by simply constructing the bounding box of all the constitutent SpatialGridDataFrame objects.
http://wiki.openstreetmap.org/index.php/Tile_usage_policy
myraster = raster(matrix(0,10,10),xmn=8,xmx=18,ymn=0,ymx=10, crs="+proj=longlat")
values(myraster) = seq(0,1,len=ncell(myraster))
myPoints = SpatialPoints(myraster, proj4string=CRS(proj4string(myraster)))[
seq(1,ncell(myraster),len=5)]
par(mar=c(0,0,0,0))
mytiles = openmap(myraster)
plot(myraster)
plot(mytiles, add=TRUE)
points(myPoints,col='red')
mytiles = openmap(myPoints,
path="b.www.toolserver.org/tiles/bw-mapnik", verbose=TRUE)
plot(myPoints)
plot(mytiles, add=TRUE)
points(myPoints,col='red')
Run the code above in your browser using DataLab