plotMap {antaresViz}R Documentation

Display results of a simulation on a map

Description

This function generates an interactive map that let the user visually explore the results of an Antares simulation. By default the function starts a Shiny gadget that let the user which variables to represent.

Usage

plotMap(
  x,
  refStudy = NULL,
  mapLayout,
  colAreaVar = "none",
  sizeAreaVars = c(),
  areaChartType = c("bar", "pie", "polar-area", "polar-radius"),
  uniqueScale = FALSE,
  showLabels = FALSE,
  popupAreaVars = c(),
  labelAreaVar = "none",
  colLinkVar = "none",
  sizeLinkVar = "none",
  popupLinkVars = c(),
  closePopupOnClick = TRUE,
  type = c("detail", "avg"),
  timeId = NULL,
  mcYear = "average",
  main = "",
  typeSizeAreaVars = FALSE,
  aliasSizeAreaVars = c(),
  compare = NULL,
  compareOpts = list(),
  interactive = getInteractivity(),
  options = plotMapOptions(),
  width = NULL,
  height = NULL,
  dateRange = NULL,
  xyCompare = c("union", "intersect"),
  h5requestFiltering = list(),
  timeSteph5 = "hourly",
  mcYearh5 = NULL,
  tablesh5 = c("areas", "links"),
  sizeMiniPlot = FALSE,
  language = "en",
  hidden = NULL,
  ...
)

Arguments

x

Object of class antaresDataList created with readAntares and containing areas and links data. It can be a list of antaresData objects. In this case, one chart is created for each object.

refStudy

An object of class antaresData created with function readAntares containing data for areas and or districts. Can also contains an opts who refer to a h5 file.

mapLayout

Object created with function mapLayout

colAreaVar

Name of a variable present in x$areas. The values of this variable are represented by the color of the areas on the map. If "none", then the default color is used for all areas.

sizeAreaVars

Vector of variables present in x$areas to associate with the size of areas on the map. If this parameter has length equal to 0, all areas have the same size. If it has length equal to one, then the radius of the areas change depending on the values of the variable choosen. If it has length greater than 1 then areas are represented by a polar area chart where the size of each section depends on the values of each variable.

areaChartType

If parameter sizeAreaVars contains multiple variables, this parameter determines the type of representation. Possible values are "bar" for bar charts, "pie" for pie charts, "polar-area" and "polar-radius" for polar area charts where the values are represented respectively by the area or the radius of the slices.

uniqueScale

If the map contains polar or bar charts, should the different variables represented use the same scale or should each variable have its own scale ? This parameter should be TRUE only if the variables have the same unit and are comparable : for instance production variables.

showLabels

Used only when sizeAreaVars contains multiple variables. If it is TRUE, then values of each variable are displayed.

popupAreaVars

Vector of variables to display when user clicks on an area.

labelAreaVar

Variable to display inside the areas. This parameter is used only if parameter sizeAreaVars contains zero or one variable.

colLinkVar

Name of a variable present in x$links. The values of this variable are represented by the color of the links on the map. If "none", then the default color is used for all links

sizeLinkVar

Name of a variable present in x$links. Its values are represented by the line width of the links on the map.

popupLinkVars

Vector of variables to display when user clicks on a link

closePopupOnClick

LogicalValue, if TRUE the popups will automatically be closed with each click. If FALSE, the popups will stay open.

type

If type="avg", the data is averaged by area/and or link and represented on the map. If it is equal to "detail", only one time step at a time. In interactive mode, an input control permits to choose the time step shown.

timeId

time id present in the data.

mcYear

If x, contains multiple Monte-Carlo scenarios, this parameter determine which scenario is displayed. Must be an integer representing the index of the scenario or the word "average". In this case data are averaged.

main

Title of the map.

typeSizeAreaVars

logical. Select sizeAreaVars using alias ? Default to FALSE

aliasSizeAreaVars

If typeSizeAreaVars is set to TRUE, name of alias. You can find the list of alias with the function showAliases

compare

An optional character vector containing names of parameters. When it is set, two charts are outputed with their own input controls. Alternatively, it can be a named list with names corresponding to parameter names and values being list with the initial values of the given parameter for each chart. See details if you are drawing a map.

compareOpts

List of options that indicates the number of charts to create and their position. Check out the documentation of compareOptions to see available options.

interactive

LogicalValue. If TRUE, then a shiny gadget is launched that lets the user interactively choose the areas or districts to display.

options

List of parameters that override some default visual settings. See the help of plotMapOptions.

width

Width of the graph expressed in pixels or in percentage of the parent element. For instance "500px" and "100%" are valid values.

height

Height of the graph expressed in pixels or in percentage of the parent element. For instance "500px" and "100%" are valid values.

dateRange

A vector of two dates. Only data points between these two dates are displayed. If NULL, then all data is displayed.

xyCompare

Use when you compare studies, can be "union" or "intersect". If union, all of mcYears in one of studies will be selectable. If intersect, only mcYears in all studies will be selectable.

h5requestFiltering

Contains arguments used by default for h5 request, typically h5requestFiltering = list(mcYears = 3)

timeSteph5

character timeStep to read in h5 file. Only for Non interactive mode.

mcYearh5

numeric mcYear to read for h5. Only for Non interactive mode.

tablesh5

character tables for h5 ("areas" "links", "clusters" or "disticts"). Only for Non interactive mode.

sizeMiniPlot

boolean variable size for miniplot

language

character language use for label. Defaut to 'en'. Can be 'fr'.

hidden

logical Names of input to hide. Defaut to NULL

...

Other arguments for manipulateWidget

Details

compare argument can take following values :

Value

An htmlwidget of class "leaflet". It can be modified with package leaflet. By default the function starts a shiny gadget that lets the user play with most of the parameters of the function. The function returns a leaflet map when the user clicks on the button "OK".

Examples

## Not run: 
mydata <- readAntares(areas = "all", links = "all", timeStep = "daily",
                      select = "nostat")

# Place areas on a map. Ths has to be done once for a given study. Then the
# object returned by "mapLayout" may be saved and reloaded with
# functions save and load

layout <- readLayout()
ml <- mapLayout(layout = layout)
save("ml", file = "ml.rda")

plotMap(x = mydata, mapLayout = ml)

# Specify the variables to use to control the color or size of elements.
plotMap(mydata, mapLayout =  ml, 
        sizeAreaVars = c("WIND", "SOLAR", "H. ROR"),
        sizeLinkVar = "FLOW LIN.")

# Change default graphical properties
plotMap(x = mydata, mapLayout = ml, options = list(colArea="red", colLink = "orange"))
plotMap(x = list(mydata, mydata), mapLayout =  ml)

# Use custom alias
setAlias("custom_alias", "short description", c("OIL", "GAS", "COAL")) 
plotMap(x = mydata, mapLayout = ml, typeSizeAreaVars = TRUE, 
    aliasSizeAreaVars = "custom_alias")
    
plotMap(x = mydata, mapLayout = ml, interactive = FALSE, 
    language = "fr", aliasSizeAreaVars = "Renouvelable", typeSizeAreaVars = TRUE)

# Use h5 for dynamic request / exploration in a study
# Set path of simulaiton
setSimulationPath(path = path1)

# Convert your study in h5 format
writeAntaresH5(path = myNewPath)

# Redefine sim path with h5 file
opts <- setSimulationPath(path = myNewPath)
plotMap(x = opts, mapLayout = ml)

# Compare elements in a single study
plotMap(x = opts, mapLayout = ml,  .compare = "mcYear")

# Compare 2 studies
plotMap(x = list(opts, opts2), mapLayout = ml)

# Compare 2 studies with argument refStudies 
plotMap(x = opts, refStudy = opts2, mapLayout = ml)
plotMap(x = opts, refStudy = opts2, mapLayout = ml, interactive = FALSE, mcYearh5 = 2) 
plotMap(x = opts, refStudy = opts2, mapLayout = ml, h5requestFiltering = 
list(mcYears = myMcYear))

## End(Not run)


[Package antaresViz version 0.17 Index]