plot.gcm: plot a Raster layer object

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

plot a Raster layer object with GRASS color map

Usage

1
plot.gcm(x, cmap, method = 2, inflate = 1, min = NA, max = NA, force.breaks = FALSE, legend = F, out = NULL, ...)

Arguments

x

Raster layer object

cmap

either path and filename of a colormap obeying GRASS colormap style or a data.frame of type gcm$gcm (see Example)

method

method to use for colormap and break calculation: 1 or 2. (see Details)

inflate

increase (>1) or decrease (<1) the number of breaks (see Details)

min

minimum value of raster layer - is calculated if NA

max

maximum accordingly

force.breaks

if method=1 and breaks are all relative you may use the linear breaks of graphics::plot if force.breaks=FALSE and legend=TRUE

legend

plain vanilla legend argument. Per default set to FALSE du to the anticipated high number of breaks

out

if out="gcm" there is no plot. Instead a list is output needed as arguments for plot.gcm.legend. It contains the color/breakmap, min and max

...

Graphical parameters. Any argument that can be passed to image.plot and to plot, such as axes=FALSE, main='title', ylab='latitude'

Details

plot.gcm evaluates the GRASS-style colormap, which is a set of major breaks and associated colors which define the color gradient between two neigboring breaks (see r.colors) method 2 (default) constructs 20 breaks intervals between each major break. This number can be modified by the factor inflate. method 1 constucts breaks intervals depending on the magnitude of the values of the Raster, e.g. if the values range between min=10 and max=100, the N=90 breaks are constructed. Use inflate to adapt the break number to you data. Not recommended if values span several orders of magnitude.

Value

plot or (if out="gcm") a list

Note

gcm uses plot from the raster package. It is designated only to work with Raster layers. Using raster stacks or bricks will lead to

Author(s)

Jan M. Holstein <holstein@uni-bremen.de>

See Also

plot.gcm.legend

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(raster)

# make raster
dat=list()
I<-0.04
C<-0.01
dat$x=seq(-1,by=0.01,len=201)
dat$y=seq(-1,by=0.01,len=201)
m<-matrix(0,nrow=201, ncol=201,byrow=TRUE)
m<-I*exp(-(((row(m)-101)/ 40)^2 + ((col(m)-101)/ 100)^2)) -C
dat$z=matrix(m, 201, 201)
r=raster(dat);plot(r)

# construct a GRASS-style colormap. Notice, that you can mix absolute and relative breaks. Notice, that you can mix varios color definitions
rstcurv<-    '-0.1      purple NA  NA
-0.01        0 0  255
-0.001         indigo  NA NA
-0.00001        cyan NA  NA
0 200:255:200 NA  NA
0.00001      yellow NA  NA
0.001      orange NA  NA
0.01         "#FF0000" NA  NA
100%   255:0:200 NA  NA'
tf<-tempfile()
writeLines(rstcurv,tf)

# check different methods, play with inflate
plot.gcm(x=r,method=1,inflate=1,cmap=rstcurv,legend=FALSE,axes=FALSE,box=FALSE)
plot.gcm(x=r,method=1,inflate=100,cmap=rstcurv,legend=FALSE,axes=FALSE,box=FALSE)
plot.gcm(x=r,method=1,inflate=1000,cmap=rstcurv,legend=FALSE,axes=FALSE,box=FALSE)
plot.gcm(x=r,method=2,inflate=1,cmap=rstcurv,legend=FALSE,axes=FALSE,box=FALSE)
plot.gcm(x=r,method=2,inflate=0.01,cmap=rstcurv,legend=FALSE,axes=FALSE,box=FALSE)

# take a look at the colormap
gcm<-plot.gcm(x=r,method=1,cmap=tf,out="gcm")
gcm

# see the difference in legend
plot.gcm.legend(gcm=gcm) # legend covers only intervalls where values exist
plot.gcm.legend(gcm=gcm$gcm) # legend covers whole range defined in colormap

janhoo/gcm documentation built on May 18, 2019, 2:38 p.m.