genPlotGIS: Plot satellite images with a GIS format

Description Usage Arguments Details Value Examples

View source: R/genPlotGIS.R

Description

This function displays satellite images with the usual format in geographic information systems (GIS), i.e., adding a scale, north arrow, and the border of the region of interest (optional).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
genPlotGIS(
  r,
  region,
  breaks,
  labels,
  zlim,
  layout,
  proj,
  nbreaks = 40,
  nlabels = 10,
  as.grid = TRUE,
  compass.rm = FALSE,
  scale.bar.rm = FALSE,
  ...
)

Arguments

r

a Raster* class object with an image or stack of images to be plotted. If r is a list of RasterStack, genPlotGIS treates the stacks as RGB images.

region

a Spatial*, projected raster*, or sf class object defining the area of interest.

breaks

a numeric vector defining the color breaks of the legend.

labels

a character vector defining the labels in the breaks of the legend.

zlim

a numeric vector defining the maximun and minimun pixel values to be mapped.

layout

a numeric vector defining rows and columns to divide the plotting area.

proj

a character or 'CRS' class object defining the coordinate reference system of the plot.

nbreaks

a numeric argument defining the default number of breaks.

nlabels

a numeric argument defining the default number of labels in the legend.

as.grid

a logical argument. If TRUE, removes the space between plotted layers.

compass.rm

a logical argument to remove the compass from the plot. FALSE by default.

scale.bar.rm

a logical argument to remove the scale bat from the plot. FALSE by default.

...

argument for nested functions:

  • tm_layout any argument accepted by the tm_layout function.

  • tm.graticules any argument accepted by the tm_graticules function. The arguments are defined as tm.graticules.arg, where arg is the tm_graticules argument name. For example, the labels.size of tm_graticules is defined as tm.graticules.labels.size.

  • tm.compass any argument accepted by the tm_compass function. The arguments are defined as tm.compass.arg, where arg is the tm_compass argument name. For example, the type of tm_compass is defined as tm.compass.type.

  • tm.scale.bar any argument accepted by the tm_scale_bar function. The arguments are defined as tm.scale.bar.arg, where arg is the tm_scale_bar argument name. For example, the text.size of tm_scale_bar is defined as tm.scale.bar.text.size.

  • tm.shape and tm.polygon refer to the region argument. Any argument accepted by the tm_shape and tm_polygon functions. The arguments are defined as tm.shape.region.arg or tm.polygon.region.arg, where arg is the tm_shape and tm_polygon argument name respectively. For example, the lwd of tm_polygon is defined as tm.polygon.region.lwd.

  • tm.shape and tm.raster refer to the r argument. Any argument accepted by the tm_shape and tm_raster functions. The arguments are defined as tm.shape.r.arg or tm.raster.r.arg, where arg is the tm_shape and tm_raster argument name respectively. For example, the legend.reverse of tm_raster is defined as tm.raster.r.legend.reverse.

  • tm.tmap.arrange any argument accepted by the tm_tmap_arrange function. The arguments are defined as tm.tmap.arrange.arg, where arg is the tm_tmap_arrange argument name. For example, the asp of tm_tmap_arrange is defined as tm.tmap.arrange.asp. This arguments are only accepted when plotting a list of stack images to plot as RGB.

Details

This is a wrapper function of tmap and hence displays any Raster* object and accepts all of its parameters. The function adds a scale, a north arrow and a polygon in the area of interest. If necessary, the function automatically reprojects the polygon to match the projection of the raster. The projection of the map can be changed by modifying the proj argument. For futher help on tmap arguements, please go the tmap reference manual.

Value

tmap class containing the plot.

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
41
42
43
44
45
## Not run: 
# Simple plot of NDVI in Navarre
genPlotGIS(ex.ndvi.navarre,
           ex.navarre)

# Using tm arguments        
genPlotGIS(ex.ndvi.navarre,
          ex.navarre,
          tm.compass.size=1,
          tm.compass.type="rose",
          tm.scale.bar.text.size=0.8,
          tm.polygon.region.lwd=6,
          tm.polygon.region.border.col="#000000",
          tm.raster.r.palette=rev(terrain.colors(40)),
          tm.raster.r.title="NDVI",
          as.grid = TRUE,
          tm.graticules.labels.size=1,
          tm.graticules.n.x=3,
          tm.graticules.n.y=3)
# Using the view mode of tmap for ploting the images in the viewer
tmap_mode("view")
genPlotGIS(ex.ndvi.navarre,
           ex.navarre,
           tm.raster.r.palette=rev(terrain.colors(40)))+
           tm_facets(as.layers=TRUE)
           
# path to the cropped and cutted MODIS images for the region of Navarre
wdir <- system.file("ExNavarreVar", package = "RGISTools")
# list all the tif files
files.mod <- list.files(wdir, pattern="\\.tif$", recursive = TRUE, full.names = TRUE)
# print the MOD09 bands
getRGISToolsOpt("MOD09BANDS")

# select the red, blue and NIR bands
img.mod.red <- raster(files.mod[1])
img.mod.blue <- raster(files.mod[3])
img.mod.green <- raster(files.mod[4])
img.mod.rgb<-varRGB(img.mod.red,img.mod.green,img.mod.blue)
genPlotGIS(ex.ndvi.navarre,
           ex.navarre)+
           tm_facets(as.layers = TRUE)+
genPlotGIS(list(img.mod.rgb),
           ex.navarre)

## End(Not run)

RGISTools documentation built on July 2, 2020, 3:58 a.m.