PlotMapPoints {HYPEtools} | R Documentation |
Plot function for mapped point information
Description
Plot mapped point information, e.g. model performances at observation sites.
Usage
PlotMapPoints(
x,
sites = NULL,
sites.subid.column = 1,
sites.groups = NULL,
bg = NULL,
bg.label.column = 1,
var.name = "",
map.type = "default",
shiny.data = FALSE,
plot.legend = TRUE,
legend.pos = "right",
legend.title = NULL,
legend.signif = 2,
col = NULL,
col.breaks = NULL,
col.labels = NULL,
col.rev = FALSE,
plot.scale = TRUE,
scale.pos = "br",
plot.arrow = TRUE,
arrow.pos = "tr",
radius = 5,
weight = 0.15,
opacity = 0.75,
fillOpacity = 0.5,
na.color = "#808080",
jitter = 0.01,
bg.weight = 0.15,
bg.opacity = 0.75,
bg.fillColor = "#e5e5e5",
bg.fillOpacity = 0.75,
plot.label = FALSE,
plot.label.size = 2.5,
plot.label.geometry = c("centroid", "surface"),
noHide = FALSE,
textOnly = FALSE,
font.size = 10,
plot.bg.label = NULL,
file = "",
width = NA,
height = NA,
units = c("in", "cm", "mm", "px"),
dpi = 300,
vwidth = 1424,
vheight = 1000,
html.name = "",
map.adj = 0,
legend.outer = FALSE,
legend.inset = c(0, 0),
pt.cex = 1,
par.cex = 1,
par.mar = rep(0, 4) + 0.1,
pch = 21,
lwd = 0.8,
add = FALSE,
map = NULL,
map.subid.column = NULL
)
Arguments
x |
Information to plot, typically model performances from imported HYPE 'subassX.txt' files. Data frame object with two columns, first column containing SUBIDs and second column containing model results to plot. See details. |
sites , map |
A |
sites.subid.column , map.subid.column |
Integer, column index in the |
sites.groups |
Named list providing groups of SUBIDs to allow toggling of point groups in Leaflet maps. Default |
bg |
A |
bg.label.column |
Integer, column index in the |
var.name |
Character string. HYPE variable name to be plotted. Mandatory for automatic color ramp selection of pre-defined
HYPE variables ( |
map.type |
Map type keyword string. Choose either |
shiny.data |
Logical, if |
plot.legend |
Logical, plot a legend along with the map. |
legend.pos |
Keyword string for legend position. For static plots, one of: |
legend.title |
Character string or mathematical expression. An optional title for the legend. If none is provided here, the name of the second column in |
legend.signif |
Integer, number of significant digits to display in legend labels. |
col |
Colors to use on the map. One of the following:
|
col.breaks |
A numeric vector, specifying break points for discretization of model result values into classes. Class boundaries will be
interpreted as right-closed, i.e upper boundaries included in class. Lowest class boundary included in lowest class as well.
Meaningful results require the lowest and uppermost breaks to bracket all model result values, otherwise there will be
unclassified white spots on the map plot. If |
col.labels |
A character vector, specifying custom labels to be used for each legend item. Works with |
col.rev |
Logical, If |
plot.scale |
Logical, plot a scale bar on map. NOTE: Scale bar may be inaccurate for geographic coordinate systems (Consider switching to projected coordinate system). |
scale.pos |
Keyword string for scalebar position for static maps. One of |
plot.arrow |
Logical, plot a North arrow in static maps. |
arrow.pos |
Keyword string for north arrow position for static maps. One of |
radius |
Numeric, radius of markers maps. See |
weight |
Numeric, weight of marker outlines in Leaflet maps. See |
opacity |
Numeric, opacity of marker outlines in Leaflet maps. See |
fillOpacity |
Numeric, opacity of markers in Leaflet maps. See |
na.color |
Character string of color to use to symbolize markers in maps which correspond to |
jitter |
Numeric, amount to jitter points with duplicate geometries. See |
bg.weight |
Numeric, weight of |
bg.opacity |
Numeric, opacity of |
bg.fillColor |
Character string of color to use to symbolize |
bg.fillOpacity |
Numeric in range 0-1, opacity of |
plot.label |
Logical, if |
plot.label.size |
Numeric, size of text for labels on default static plots. See |
plot.label.geometry |
Keyword string to select where plot labels should be displayed on the default static plots. Either |
noHide |
Logical, set to |
textOnly |
Logical, set to |
font.size |
Numeric, font size (px) for marker labels in Leaflet maps. |
plot.bg.label |
String, if |
file |
Save map to an image file by specifying the path to the desired output file using this argument. File extension must be specified. See |
width |
Numeric, width of output plot for static maps in units of |
height |
Numeric, height of output plot for static maps in units of |
units |
Keyword string for units to save static map. One of |
dpi |
Integer, resolution to save static map. See |
vwidth |
Numeric, width of the exported Leaflet map image in pixels. See |
vheight |
Numeric, height of the exported Leaflet map image in pixels. See |
html.name |
Save Leaflet map to an interactive HTML file by specifying the path to the desired output file using this argument. File extension must be specified.
See |
map.adj |
Numeric, map adjustment in direction where it is smaller than the plot window. A value of |
legend.outer |
Logical. If |
legend.inset |
Numeric, inset distance(s) from the margins as a fraction of the plot region for legend, scale and north arrow.
See |
pt.cex |
Numeric, plot point size expansion factor, works on top of |
par.cex |
Numeric, character expansion factor. See description of |
par.mar |
Plot margins as in |
pch , lwd |
Integer, plotting symbol and line width. See |
add |
Logical, default |
Details
PlotMapPoints
can be used to print point information on a mapped surface. The primary target are model performance
measures as written to
HYPE 'subassX.txt' files, but
color scale and break point arguments are flexible enough to also be used with e.g. HYPE output variables or other data.
PlotMapOutput
can return static plots or interactive Leaflet maps depending on value provided for the argument map.type
.
For backwards compatibility, legacy static plots can still be generated by setting map.type
to legacy
. For legacy plots, legend.pos
and
map.adj
should be chosen so that legend and map do not overlap, and the legend position can be fine-tuned using
argument legend.inset
. This is particularly useful for legend titles with more than one line. For details on inset
specification for the default maps, see inset
in legend
.
Value
For default static maps, PlotMapPoints
returns an object of class ggplot
. This plot can also be assigned to a variable in the environment.
For interactive Leaflet maps, PlotMapOutput
returns an object of class leaflet
. For legacy static plots, PlotMapOutput
returns a plot to the
currently active plot device and invisibly an object of class SpatialPointsDataFrame
as provided in argument sites
, with plotted values and color codes added as columns
in the data slot.
See Also
ReadSubass
for HYPE result import; ReadMapOutput
for a similar plot function
Examples
# Import plot data and subbasin points
require(sf)
te1 <- ReadSubass(filename = system.file("demo_model",
"results", "subass1.txt", package = "HYPEtools"))
te2 <- st_read(dsn = system.file("demo_model",
"gis", "Nytorp_station.gpkg", package = "HYPEtools"))
te2$SUBID <- 3587 # add station SUBID to point
te3 <- st_read(dsn = system.file("demo_model",
"gis", "Nytorp_map.gpkg", package = "HYPEtools"))
# plot NSE performance for discharge
PlotMapPoints(x = te1[, 1:2], sites = te2, sites.subid.column = 4, bg = te3)