Downloads map tiles from Openstreetmap.org and other servers.
openmap(x, zoom,
path="http://tile.openstreetmap.org/",
maxTiles = 9,
crs=projection(x),
buffer=0, fact=1,
verbose=getOption('mapmiscVerbose'),
cachePath=getOption('mapmiscCachePath')
) osmTiles(name, xyz, suffix)
openmapAttribution(name,
type=c('text','latex','markdown','html', 'auto'),
short=FALSE)
An extent
or any spatial object (raster, Spatial*)
from which an extent can be obtained.
the zoom level, when missing it will be determined by maxTiles.
Source of map tiles, see http://diseasemapping.r-forge.r-project.org/mapLayers.html.
If zoom is missing, zoom will be chosen such that the number of map tiles is less than or equl to this number.
Projection for the output, defaulting to the same projection as
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 crs
is NA
or missing and x
has no crs, long-lat is used.
Extend the extent for which the map is requested, in units
of x
. Can be negative, or a vector of length 2 for different x and y
extensions
Passed to disaggregate
before
reprojecting if fact>1
,
helps to produce a clearer image.
Print information about map images being downloaded, defaults to FALSE
.
Location to store downloaded map images, defaults to tempdir()
name of a tile path, if missing a vector of all available tile paths
is returned. name
can be any of the names of the vector returned when
name
is unspecified.
format for the attribution
short or long attribution
format of xyz coordinates in URL's
string to append to URL's, i.e. '.png'
openmap
returns a Raster
with indexed colours,
or a RasterBrick
brick
, with 'red', 'green' and 'blue' layers.
openmapAttribution
returns a character string.
These functions download, display, and manipulate map tiles stored in a standard way either on a web server or a local folder.
Map tiles are a set of PNG images that span the world at a set of zoom
levels. Zoom level 1 has four 256x256 pixel tiles
in a 2x2 pattern over the whole world. In general, zoom level n has
See http://diseasemapping.r-forge.r-project.org/mapLayers.html for a full set of map tiles.
Be sure to attribute any maps you publish, the osmAttribution
function will assist. If type = 'auto'
then markdown format will be used unless a variable mdToTex
is defined and equal to TRUE
.
# NOT RUN {
data("netherlands")
plot(nldTiles)
openmapAttribution(nldTiles, short=TRUE, type='markdown')
openmapAttribution("stamen-toner", type='text')
myraster = raster(matrix(0,10,10),xmn=8,xmx=18,ymn=0,ymx=10,
crs="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
values(myraster) = seq(0,1,len=ncell(myraster))
myPoints = SpatialPoints(myraster, proj4string=CRS(proj4string(myraster)))[
seq(1,ncell(myraster),len=5)]
names(osmTiles())
# }
# NOT RUN {
mytiles = openmap(myraster, zoom=6)
map.new(myraster)
plot(mytiles, add=TRUE)
points(myPoints,col='red')
mytiles = openmap(myPoints,
path='waze', verbose=TRUE)
map.new(myPoints)
plotRGB(mytiles, add=TRUE)
points(myPoints, col='red')
openmapAttribution(mytiles)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab