Package 'mrwaterplots'

Title: plotting library for mrwater outputs
Description: The mrwaterplots package plots outputs from mrwater library.
Authors: Felicitas Beier [aut, cre], Jens Heinke [aut], Patrick von Jeetze [aut], Jan Philipp Dietrich [aut]
Maintainer: Felicitas Beier <[email protected]>
License: LGPL-3 | file LICENSE
Version: 1.1.1
Built: 2025-03-06 10:23:23 UTC
Source: https://github.com/pik-piam/mrwaterplots

Help Index


mrwaterplots: plotting library for mrwater outputs

Description

The mrwaterplots package plots outputs from mrwater library.

Author(s)

Maintainer: Felicitas Beier [email protected]

Authors:

See Also

Useful links:


downloadNaturalEarth

Description

download Natural Earth shape files

Usage

downloadNaturalEarth()

Author(s)

Felicitas Beier

See Also

downloadSource()

Examples

## Not run: 
a <- downloadSource("NaturalEarth")

## End(Not run)

plotBivariateMap

Description

This function plots a raster object of halfdegree resolution (with 67420 grid cells) and saves it as PDF

Usage

plotBivariateMap(
  x,
  y,
  xlab = NULL,
  ylab = NULL,
  breaks = 4,
  projection =
    "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
  bivariatelegendstyle = 1,
  colNA = "#d9d9d9",
  outputfolder = ".\\",
  name = "name",
  title = "",
  ylim = c(-6500000, 8300000),
  xlim = c(-12577316, 15581284),
  outputtype = "png"
)

Arguments

x

First MAgPIE object in grid-cellular (67420) resolution to be plotted

y

Second MAgPIE object in grid-cellular (67420) resolution to be plotted in same map

xlab

name of first object for legend x label

ylab

name of second object of legend y label

breaks

Breaks in bivariate legend

projection

Choose projection. Currently available options: "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for EqualEarth projection; "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for RobinsonProj; and "+proj=longlat +datum=WGS84" for LatLon projection

bivariatelegendstyle

number between 1-9 to choose pre-defined bivariate legend colors

colNA

color for NAs (default: "#d9d9d9" (gray))

outputfolder

Path to which plot should be saved

name

Title of plot (default: "name")

title

Plot title displayed in the plot

ylim

y-axis limits of plot (default: c(-6500000, 8300000))

xlim

x-axis limits of plot (default: c(-12577316, 15581284))

outputtype

Output type: pdf or jpeg

Value

map as pdf

Author(s)

Felicitas Beier


plotCustomLegend

Description

This function plots a customized legend

Usage

plotCustomLegend(
  ticks,
  colorVectors,
  boxTitles,
  legendTitle = "legend title (unit)",
  legendPosX = 0.5,
  legendPosY = 0.15,
  boxWidth = 0.4,
  boxHeight = 0.05
)

Arguments

ticks

Ticks of legend (usually legendBreaks of plot)

colorVectors

List of color vectors with length ticks-1. Number of vectors within list defines number of box rows in legend

boxTitles

Title of boxes within legend. Should be same as number of vectors

legendTitle

Title of legend. If no title wanted choose NULL.

legendPosX

Controls the horizontal position (from left to right), i.e., the starting point of the legend box (default: 0.5 (i.e., center)) Note: should be set relative to xlim and ylim of plot for which legend is produced (e.g., mean(xlim))

legendPosY

Controls the vertical position (from bottom to top), i.e., the middle of the whole legend box (default: 0.15 (i.e., close to bottom)) Note: should be set relative to xlim and ylim of plot for which legend is produced (e.g., ylim[1] + (ylim[2] - ylim[1]) * 0.05).

boxWidth

Controls the total width. Note: should be set relative to xlim and ylim of plot for which legend is produced (e.g., (xlim[2] - xlim[1]) * 0.3).

boxHeight

Controls the individual row height Note: should be set relative to xlim and ylim of plot for which legend is produced (e.g., (ylim[2] - ylim[1]) * 0.025).

Value

legend to be added on previously plotted graph

Author(s)

Felicitas Beier


plotMap

Description

This function plots a raster object of halfdegree resolution (with 67420 grid cells) and saves it as PDF

Usage

plotMap(
  x,
  projection =
    "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
  outputfolder = ".\\",
  name = "name",
  title = "",
  titlesize = 3,
  ylim = c(-6500000, 8300000),
  xlim = c(-12577316, 15581284),
  legendcolor = c("#7f0000", "#b30000", "#d7301f", "#ef6548", "#fc8d59", "#fdbb84",
    "#fdd49e", "#fee8c8", "#fff7ec", "#045a8d"),
  colNA = "#d9d9d9",
  legendlimit = c(0, 1),
  legendbreaks = seq(0, 1, 0.1),
  legendname = "legendname",
  legendtextsize = 2,
  outputtype = "png",
  minVal = NULL,
  maxVal = NULL
)

Arguments

x

MAgPIE object in grid-cellular (67420) resolution to be plotted

projection

Choose projection. Currently available options: "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for EqualEarth projection; "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for RobinsonProj; and "+proj=longlat +datum=WGS84" for LatLon projection

outputfolder

Path to which plot should be saved

name

Title of plot (default: "name")

title

Plot title displayed in the plot

titlesize

Text size of plot title

ylim

y-axis limits of plot (default: c(-6500000, 8300000))

xlim

x-axis limits of plot (default: c(-12577316, 15581284))

legendcolor

vector of colors

colNA

color for NAs (default: "#d9d9d9" (gray))

legendlimit

vector with min and max of legend (default: c(0, 1))

legendbreaks

vector of legend breaks (default: seq(0, 1, 0.1))

legendname

legend name as character (default: "legendname")

legendtextsize

text size of legendtext

outputtype

Output type: pdf or jpeg

minVal

minimum value at which x should be chopped

maxVal

maximum value at which x should be chopped

Value

map as pdf, jpg or png

Author(s)

Felicitas Beier, Jens Heinke


plotMapDiscrete

Description

This function plots a raster object of halfdegree resolution (with 67420 grid cells) and saves it as PDF

Usage

plotMapDiscrete(
  x,
  projection =
    "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
  outputfolder = ".\\",
  name = "name",
  title = "",
  titlesize = 3,
  ylim = c(-6500000, 8300000),
  xlim = c(-12577316, 15581284),
  legendcolor = c("#7f0000", "#b30000", "#d7301f", "#ef6548", "#fc8d59", "#fdbb84",
    "#fdd49e", "#fee8c8", "#fff7ec", "#045a8d"),
  colNA = "#d9d9d9",
  legendbreaks = seq(0, 1, 0.1),
  legend = NULL,
  legendname = "legendname",
  legendtextsize = 2,
  outputtype = "png",
  minVal = NULL,
  maxVal = NULL
)

Arguments

x

MAgPIE object in grid-cellular (67420) resolution to be plotted

projection

Choose projection. Currently available options: "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for EqualEarth projection; "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for RobinsonProj; and "+proj=longlat +datum=WGS84" for LatLon projection

outputfolder

Path to which plot should be saved

name

Title of plot (default: "name")

title

Plot title displayed in the plot

titlesize

Textsize of plot title

ylim

y-axis limits of plot (default: c(-6500000, 8300000))

xlim

x-axis limits of plot (default: c(-12577316, 15581284))

legendcolor

vector of colors

colNA

color for NAs (default: "#d9d9d9" (gray))

legendbreaks

vector of legend breaks (default: seq(0, 1, 0.1))

legend

legend element names (if non-numeric characters shall be returned). (default: NULL, then legendbreaks defines displayed legend elements)

legendname

legend name as character (default: "legendname")

legendtextsize

text size of legend text

outputtype

Output type: pdf or jpeg

minVal

minimum value at which x should be chopped

maxVal

maximum value at which x should be chopped

Value

map as pdf, jpg or png

Author(s)

Felicitas Beier, Jens Heinke


plotMapLayered

Description

This function plots several magpie objects of halfdegree resolution (with 67420 grid cells) as overlayed map

Usage

plotMapLayered(
  x,
  projection =
    "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
  outputfolder = ".\\",
  name = "name",
  title = "",
  ylim = c(-6500000, 8300000),
  xlim = c(-12577316, 15581284),
  legendcolor = list(c("#dfc27d", "#bf812d", "#8c510a", "#543005"), c("#80cdc1",
    "#35978f", "#01665e", "#003c30")),
  legendtitles = c("scale1", "scale2"),
  legendname = "legendtitle (unit)",
  naObject = NULL,
  legendlimit = c(0, 1),
  legendbreaks = seq(0, 1, 0.25),
  outputtype = "png",
  minVal = NULL,
  maxVal = NULL
)

Arguments

x

list of MAgPIE objects in grid-cellular (67420) resolution to be plotted

projection

Choose projection. Currently available options: "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for EqualEarth projection; "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for RobinsonProj; and "+proj=longlat +datum=WGS84" for LatLon projection

outputfolder

Path to which plot should be saved

name

Title of plot (default: "name")

title

Plot title displayed in the plot

ylim

y-axis limits of plot (default: c(-6500000, 8300000))

xlim

x-axis limits of plot (default: c(-12577316, 15581284))

legendcolor

List of vector of colors of the same length as the list of objects provided

legendtitles

Vector for title for legendcolors. Should have the same length as the list of legendcolor

legendname

legend name as character (default: "legendname")

naObject

magpie object that defines which areas to mask out as NA with 1 being the ones to be masked out and 0 the ones that are transparent, i.e. show the previous plots

legendlimit

vector with min and max of legend (default: c(0, 1))

legendbreaks

vector of legend breaks (default: seq(0, 1, 0.1))

outputtype

Output type: pdf or jpeg or png

minVal

minimum value at which x should be chopped

maxVal

maximum value at which x should be chopped

Value

map as pdf, jpg or png

Author(s)

Felicitas Beier, Jens Heinke


toolCellAreaShare

Description

This function calculates the share of total grid cell area for a given cellular magpie object with 67420 grid cells

Usage

toolCellAreaShare(x)

Arguments

x

MAgPIE object in grid-cellular (67420) resolution containing area in Mha for which cell area share is to be calculated

Value

magpie object in cellular resolution

Author(s)

Felicitas Beier


toolPrepareLandMask

Description

This function sets up the land mask and country polygons to plot magpie objects using raster/terra with an Equal Earth Projection

Usage

toolPrepareLandMask(
  projection =
    "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
)

Arguments

projection

Choose projection. Currently available options: "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for EqualEarth projection; "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for RobinsonProj; and "+proj=longlat +datum=WGS84" for LatLon projection

Value

list of raster files

Author(s)

Felicitas Beier, Jens Heinke, Patrick v. Jeetze, Jan P. Dietrich


toolRasterTransform

Description

This function transforms a cellular magpie object with 67420 grid cells to a raster object that can be plotted in the chosen projection

Usage

toolRasterTransform(
  x,
  projection =
    "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
)

Arguments

x

MAgPIE object in grid-cellular (67420) resolution to be transformed to raster

projection

Choose projection. Currently available options: "+proj=eqearth +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for EqualEarth projection; "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" for RobinsonProj; "+proj=moll" for Mollweide; and "+proj=longlat +datum=WGS84" for LatLon projection

Value

magpie object in cellular resolution

Author(s)

Felicitas Beier