getSpatialMap_mat: Replot raster matrix

View source: R/getSpatialMap.R

getSpatialMap_matR Documentation

Replot raster matrix

Description

replot the matrix output from getSpatialMap, when output = 'data' or output is default value.

Usage

getSpatialMap_mat(
  matrix,
  title_d = NULL,
  catchment = NULL,
  point = NULL,
  output = "data",
  name = NULL,
  info = FALSE,
  scale = "identity",
  color = NULL,
  ...
)

Arguments

matrix

A matrix raster, should be the result of getSpatialMap(), output should be default or 'data'

title_d

A string showing the title of the plot, defaut is NULL.

catchment

A catchment file geting from shp2cat() in the package, if a catchment is available for background.

point

A dataframe, showing other information, e.g., location of the gauging stations. The the data.frame should be with columes "name, lon, lat, z, value".

output

A string showing the type of the output, if output = 'ggplot', the returned data can be used in ggplot and getSpatialMap_comb(); if output = 'plot', the returned data is the plot containing all layers' information, and can be plot directly or used in grid.arrange; if not set, the raster matrix data will be returned.

name

If output = 'ggplot', name has to be assigned to your output, in order to differentiate different outputs in the later multiplot using getSpatialMap_comb.

info

A boolean showing whether the information of the map, e.g., max, mean ..., default is FALSE.

scale

A string showing the plot scale, 'identity' or 'sqrt'.

color

Most of time you don't have to set this, but if you are not satisfied with the default color, you can set your own palette here. e.g., color = c('red', 'blue'), then the value from lowest to highest, will have the color from red to blue. More info about color, please check ?palette().

...

title, x, y showing the title and x and y axis of the plot. e.g. title = 'aaa' default is about precipitation.

Value

A matrix representing the raster map is returned, and the map is plotted.

References

  • R Core Team (2015). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.

  • Hadley Wickham (2007). Reshaping Data with the reshape Package. Journal of Statistical Software, 21(12), 1-20. URL http://www.jstatsoft.org/v21/i12/.

  • Hadley Wickham (2011). The Split-Apply-Combine Strategy for Data Analysis. Journal of Statistical Software, 40(1), 1-29. URL http://www.jstatsoft.org/v40/i01/.

  • Original S code by Richard A. Becker and Allan R. Wilks. R version by Ray Brownrigg. Enhancements by Thomas P Minka <tpminka at media.mit.edu> (2015). maps: Draw Geographical Maps. R package version 2.3-11. https://CRAN.R-project.org/package=maps

  • Pebesma, Edzer, and Roger Bivand. 2023a. Sp: Classes and Methods for Spatial Data. https://CRAN.R-project.org/package=sp.

  • Roger Bivand and Colin Rundel (2015). rgeos: Interface to Geometry Engine - Open Source (GEOS). R package version 0.3-11. https://CRAN.R-project.org/package=sf

Examples


## Not run: 
data(tgridData)# the result of \code{loadNcdf}
#the output type of has to be default or 'data'.
a1 <- getSpatialMap(tgridData, method = 'mean')
a2 <- getSpatialMap(tgridData, method = 'max')
a3 <- getSpatialMap(tgridData, method = 'winter')
a4 <- getSpatialMap(tgridData, method = 'summer')
#For example, if we want to investigate the difference between mean value and max.

a5 <- a2 - a1
getSpatialMap_mat(a4)

#Or to investigate the difference between winter value and summer value.
a6 <- a3 - a4
getSpatialMap_mat(a6)


## End(Not run)


# More examples can be found in the user manual on https://yuanchao-xu.github.io/hyfo/


Yuanchao-Xu/hyfo documentation built on Aug. 29, 2023, 4:57 a.m.