Save a map to disk intended to be part of a as a still image sequence of one of three types: networks, tiles, or lines.
save_map(x, z.name = NULL, z.range = NULL, dir = getwd(), lon = 0,
lat = 0, n.period = 360, n.frames = n.period, ortho = TRUE,
col = NULL, type, suffix = NULL, rotation.axis = 23.4,
png.args = list(width = 1920, height = 1080, res = 300, bg = "transparent"),
save.plot = TRUE, return.plot = FALSE, num.format = 4)
a data frame containing networks, tiles, or lines information.
character, the column name of the data (z
) variable in x
. Only needed for type="maptiles"
and type="polygons"
numeric vector, the full known range for the data values across all x
objects, not just the current one, e.g. c(0, 5)
.
png output directory. Defaults to working directory.
starting longitude for rotation sequence or vector of arbitrary longitude sequence.
fixed latitude or vector of arbitrary latitude sequence.
intended length of the period.
intended number of frames in animation.
use an orthographic projection for globe plots. Defaults to TRUE
.
sensible default colors provided for each type
the type of plot, one of "network"
, maptiles
, maplines
, or polygons
.
character, optional suffix to be pasted onto output filename.
the rotation axis used when ortho=TRUE
for globe plots. Defaults to 23.4 degrees.
a list of arguments passed to png
.
save the plot to disk. Defaults to TRUE
. Typically only set to FALSE
for demonstrations and testing.
return the ggplot object. Defaults to FALSE
. Only intended for single-plot demonstrations and testing, not for still image sequence automation.
number of digits including any leading zeros for image sequence frame numbering. Defaults to 4, i.e. 0001, 0002, ...
.
usually returns NULL after writing file to disk as a side effect. May return a ggplot object but be careful not to use this option if looping over many plots.
save_map
takes a specific type of data frame catering to networks, tiles, or lines.
It plots a 3D globe map with ortho=TRUE
(default) or a flat map (ortho=FALSE
).
For flat maps, lon
, lat
, n.period
, n.frames
, and rotation.axis
are ignored.
For plotting on a globe, lon
and lat
are used to describe the field of view or the visible hemisphere.
n.period
relates is eithe the period of rotation of the globe or the length of the non-repeating, arbitrary coordinates sequence.
n.frames
is always the explicit number of frames that will make up an animation
regardless of the length of the series of data frames x
to be plotted or the length of the rotational period or coordinates sequence.
z.name
is relevant only for fill color when drawing tiles or polygons.
z.range
is important for type="maptiles"
because it is used to ensure colors are mapped to values consistently across all plots.
This is not only for the case of changing data values across a series of plots of different data frames x
.
There are also changes in the range of values for a fixed data frame when it is plotted repeatedly as the globe is rotated and different hemispheres of the map
(different data subsets) are in view across the image sequence. z.range
will default to the range of the given x
if not provided.
The color
argument is used differently depending on type
.
For maplines
it is a single color. Additional colors in a vector are ignored. For other plot types it must be a vector.
maptiles
and polygons
require a vector of at least two colors to produce a palette for their color gradient.
network
is a special case which assumes four colors in the following order: background line, foreground line, background point, foreground point.
The four colors are layered in the plot in this order. Semi-transparent colors can work well in this context. Additional colors are ignored.
If col=NULL
(default) sensible default colors are provided for each plot type.
The png output directory will be created if it does not exist, recursively if necessary. The default is the working directory.
This is ignored if save.plot=FALSE
.
type="polygons"
is only recommended for use with flat maps, not the orthographic projection. See the vignette for an example and description of the issue.
For globe plots it is best to rasterize polygons and use type="maptiles"
for better results in exchange for increased processing time.