MapRegionalSources {HYPEtools} | R Documentation |
Map regional irrigation source connection as spatial lines
Description
By default, this function creates an sf
object which contains regional irrigation connections between
source and target HYPE sub-catchments. However, this function can also be used to create interactive Leaflet maps.
Usage
MapRegionalSources(
data,
map,
map.subid.column = 1,
group.column = NULL,
group.colors = NULL,
digits = 3,
progbar = FALSE,
map.type = "default",
plot.scale = TRUE,
plot.searchbar = FALSE,
weight = 0.5,
opacity = 1,
fillColor = "#4d4d4d",
fillOpacity = 0.25,
line.weight = 5,
line.opacity = 1,
seed = NULL,
darken = 0,
font.size = 10,
file = "",
vwidth = 1424,
vheight = 1000,
html.name = ""
)
Arguments
data |
Dataframe, containing a column |
map |
A |
map.subid.column |
Integer, index of the column in |
group.column |
Integer, optional index of the column in |
group.colors |
Named list providing colors for connection groups in Leaflet maps. List names represent the names of the groups in the |
digits |
Integer, number of digits to which irrigation connection lengths are rounded to. |
progbar |
Logical, display a progress bar while calculating. |
map.type |
Map type keyword string. Choose either |
plot.scale |
Logical, include a scale bar on Leaflet maps. |
plot.searchbar |
Logical, if |
weight |
Numeric, weight of subbasin boundary lines in Leaflet maps. Used if |
opacity |
Numeric, opacity of subbasin boundary lines in Leaflet maps. Used if |
fillColor |
String, color of subbasin polygons in Leaflet maps. Used if |
fillOpacity |
Numeric, opacity of subbasin polygons in Leaflet maps. Used if |
line.weight |
Numeric, weight of connection lines in Leaflet maps. See |
line.opacity |
Numeric, opacity of connection lines in Leaflet maps. See |
seed |
Integer, seed number to to produce repeatable color palette. |
darken |
Numeric specifying the amount of darkening applied to the random color palette. Negative values will lighten the palette. See |
font.size |
Numeric, font size (px) for subbasin labels in Leaflet maps. |
file |
Save a Leaflet map to an image file by specifying the path to the desired output file using this argument. File extension must be specified.
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 a 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 |
Details
MapRegionalSources
can return static plots or interactive Leaflet maps depending on value provided for the argument map.type
.
By default, MapRegionalSources
creates an sf
object from HYPE SUBID centerpoints using a table of SUBID pairs. Regional
irrigation sources in HYPE are transfers from outlet lakes or rivers in a source sub-catchment to the soil storage of irrigated SLC classes
(Soil, Land use, Crop) in a target sub-catchment. If map.type
is set to "leaflet", then MapRegionalSources
returns an object of class leaflet
.
Value
For default static maps, MapRegionalSources
returns an sf
object containing columns SUBID
(irrigation target
sub-catchment), REGSRCID
(irrigation source sub-catchment), and Length_[unit]
(distance between sub-catchments) where
'unit' is the actual length unit of the distances. The projection of the returned object is always identical to the projection of
argument map
. For interactive Leaflet maps, PlotMapOutput
returns an object of class leaflet
. If map
contains
polygon data, then the interactive map will include the polygons as a background layer.
Examples
# Import subbasin centroids and subbasin polygons (to use as background)
require(sf)
te1 <- st_read(dsn = system.file("demo_model", "gis",
"Nytorp_centroids.gpkg", package = "HYPEtools"))
te2 <- st_read(dsn = system.file("demo_model", "gis",
"Nytorp_map.gpkg", package = "HYPEtools"))
# Create dummy MgmtData file with irrigation links
te3 <- data.frame(SUBID = c(3594, 63794), REGSRCID = c(40556, 3486))
# Plot regional irrigation links between subbasins with subbasin outlines as background
MapRegionalSources(data = te3, map = te1, map.subid.column = 25)
plot(st_geometry(te2), add = TRUE, border = 2)