Learn R Programming

mapview (version 1.1.0)

plainView: View raster objects interactively without background map but in any CRS

Description

this function produces an interactive view of the specified raster object(s) on a plain grey background but for any CRS.

Usage

"plainView"(x, maxpixels = mapviewGetOption("plainview.maxpixels"), col.regions = mapviewGetOption("raster.palette")(256), at, na.color = mapviewGetOption("na.color"), verbose = mapviewGetOption("verbose"), layer.name = deparse(substitute(x, env = parent.frame())), gdal = TRUE, ...)
"plainView"(x, r = 3, g = 2, b = 1, na.color = mapviewGetOption("na.color"), maxpixels = mapviewGetOption("plainview.maxpixels"), layer.name = deparse(substitute(x, env = parent.frame())), ...)
"plainView"(x, zcol = 1, ...)
"plainview"(...)

Arguments

x
a raster* object
maxpixels
integer > 0. Maximum number of cells to use for the plot. If maxpixels < ncell(x), sampleRegular is used before plotting.
col.regions
color (palette).See levelplot for details.
at
the breakpoints used for the visualisation. See levelplot for details.
na.color
color for missing values
verbose
should some details be printed during the process
layer.name
the name of the layer to be shown on the map
gdal
logical. If TRUE (default) gdalUtils::gdal_translate is used to create the png file for display when possible. See details for further information.
...
additional arguments passed on to repective functions. See addRasterImage, addCircles, addPolygons, addPolylines for details
r
integer. Index of the Red channel, between 1 and nlayers(x)
g
integer. Index of the Green channel, between 1 and nlayers(x)
b
integer. Index of the Blue channel, between 1 and nlayers(x)
zcol
attribute name or column number in attribute table of the column to be rendered

Methods (by class)

Details

If the raster object is not in memory (i.e. if raster::inMemory is FLASE) and argument gdal is set to TRUE (default) gdalUtils::gdal_translate is used to translate the rsater object to a png file to be rendered in the viewer/browser. This is fast for large rasters. In this case, argument maxpixels is not used, instead the image is rendered in original resolution. However, this means that RasterLayers will be shown in greyscale. If you want to set a color palette manually, use gdal = FALSE and (optionally provide) col.regions.

Examples

Run this code
## Not run: 
# plainView()
# 
# ### raster data ###
# library(sp)
# library(raster)
# 
# data(meuse.grid)
# coordinates(meuse.grid) = ~x+y
# proj4string(meuse.grid) <- CRS("+init=epsg:28992")
# gridded(meuse.grid) = TRUE
# meuse_rst <- stack(meuse.grid)
# 
# # raster stack
# m1 <- plainView(poppendorf[[5]])
# m1
# 
# # SpatialPixelsDataFrame
# plainView(meuse.grid, zcol = "soil")
# 
# 
# ### point vector data ###
# ## SpatialPointsDataFrame ##
# data(meuse)
# coordinates(meuse) <- ~x+y
# proj4string(meuse) <- CRS("+init=epsg:28992")
# 
# # all layers of meuse
# plainView(meuse, burst = TRUE)
# 
# # only one layer, all info in popups
# plainView(meuse)
# 
# ## SpatialPoints ##
# meuse_pts <- as(meuse, "SpatialPoints")
# plainView(meuse_pts)
# 
# 
# 
# ### overlay vector on top of raster ###
# plainView(meuse.grid, zcol = "ffreq") + meuse
# 
# ### polygon vector data ###
# data("gadmCHE")
# m <- plainView(gadmCHE)
# m
# 
# ## points on polygons ##
# centres <- data.frame(coordinates(gadmCHE))
# names(centres) <- c("x", "y")
# coordinates(centres) <- ~ x + y
# projection(centres) <- projection(gadmCHE)
# m + centres
# 
# ### lines vector data
# data("atlStorms2005")
# plainView(atlStorms2005)
# plainView(atlStorms2005, burst = TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab