From 5895d07242faf0cb583aaefc9e30051202daeeb3 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 8 Feb 2024 09:06:47 -0500 Subject: [PATCH 1/4] separate tm_grid and tm_graticules docs --- R/tm_layers_aux.R | 33 ++++++--- man/tm_graticules.Rd | 155 +++++++++++++++++++++++++++++++++++++++++++ man/tm_grid.Rd | 81 ++++++++++------------ 3 files changed, 213 insertions(+), 56 deletions(-) create mode 100644 man/tm_graticules.Rd diff --git a/R/tm_layers_aux.R b/R/tm_layers_aux.R index b22746f6..99dbb43a 100644 --- a/R/tm_layers_aux.R +++ b/R/tm_layers_aux.R @@ -58,9 +58,18 @@ tm_tiles = function(server = NULL, alpha = NULL, zoom = NULL, zindex = NA, group #' @export leaflet::providers -#' @name tm_graticules -#' @rdname tm_grid + +#' Coordinate grid / graticule lines +#' +#' Draw latitude and longitude graticules. It creates a [`tmap-element`] that draws coordinate grid lines. It serves as a +#' layer that can be drawn anywhere between other layers. See [tm_grid()] for +#' drawing horizontal lines. +#' +#' @inheritParams tm_grid +#' @inheritDotParams tm_grid #' @export +#' @example ./examples/tm_grid.R + tm_graticules = function(x = NA, y = NA, n.x = NA, @@ -77,11 +86,13 @@ tm_graticules = function(x = NA, #' Coordinate grid / graticule lines #' +#' @description +#' * `tm_grid()` draws horizontal and vertical lines according to the +#' coordinate system of the (master) shape object. +#' #' Creates a [`tmap-element`] that draws coordinate grid lines. It serves as a -#' layer that can be drawn anywhere between other layers. -#' By default, `tm_grid()` draws horizontal and vertical lines according to the -#' coordinate system of the (master) shape object. Latitude and longitude -#' graticules are drawn with `tm_graticules()`. +#' layer that can be drawn anywhere between other layers. See [tm_graticules()] +#' to draw latitude and longitude graticules. #' #' @param x X coordinates for vertical grid lines. If `NA`, it is specified #' with a pretty scale and `n.x`. @@ -130,16 +141,16 @@ tm_graticules = function(x = NA, #' instead of using negative coordinates for west and south (so it assumes that #' the coordinates are positive in the north-east direction). #' @param labels.margin.x Margin between tick labels of x axis and the frame. -#' Note that when `labels.inside.frame == FALSE` and `ticks == TRUE`, +#' Note that when `labels.inside.frame = FALSE` and `ticks = TRUE`, #' the ticks will be adjusted accordingly. #' @param labels.margin.y Margin between tick labels of y axis and the frame. -#' Note that when `labels.inside.frame == FALSE` and `ticks == TRUE`, +#' Note that when `labels.inside.frame = FALSE` and `ticks = TRUE`, #' the ticks will be adjusted accordingly. #' @param labels.space.x Space that is used for the labels and ticks for the x-axis -#' when `labels.inside.frame == FALSE`. By default, it is determined automatically +#' when `labels.inside.frame = FALSE`. By default, it is determined automatically #' using the widths and heights of the tick labels. The unit of this parameter is text line height. #' @param labels.space.y Space that is used for the labels and ticks for the y-axis -#' when `labels.inside.frame == FALSE`. By default, it is determined automatically +#' when `labels.inside.frame = FALSE`. By default, it is determined automatically #' using the widths and heights of the tick labels. The unit of this parameter is text line height. #' @param labels.inside.frame Show labels inside the frame? By default `FALSE`. #' @param ticks If `labels.inside.frame = FALSE`, should ticks can be drawn between the labels and the frame? @@ -161,7 +172,7 @@ tm_graticules = function(x = NA, #' can be switched on and off. Options: `"radio"` for radio buttons (meaning only one group can be shown), #' `"check"` for check boxes (so multiple groups can be shown), and `"none"` #' for no control (the group cannot be (de)selected). -#' @param ... Arguments passed on to [tm_grid()] +#' @param ... Used to catch deprecated arguments from tmap v3. #' @export #' @example ./examples/tm_grid.R tm_grid = function(x = NA, diff --git a/man/tm_graticules.Rd b/man/tm_graticules.Rd new file mode 100644 index 00000000..4c4993b7 --- /dev/null +++ b/man/tm_graticules.Rd @@ -0,0 +1,155 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tm_layers_aux.R +\name{tm_graticules} +\alias{tm_graticules} +\title{Coordinate grid / graticule lines} +\usage{ +tm_graticules( + x = NA, + y = NA, + n.x = NA, + n.y = NA, + crs = 4326, + labels.format = list(suffix = intToUtf8(176)), + labels.cardinal = TRUE, + ... +) +} +\arguments{ +\item{x}{X coordinates for vertical grid lines. If \code{NA}, it is specified +with a pretty scale and \code{n.x}.} + +\item{y}{Y coordinates for horizontal grid lines. If \code{NA}, it is specified +with a pretty scale and \code{n.y}.} + +\item{n.x}{Preferred number of grid lines for the x axis. For the labels, +a \code{\link[=pretty]{pretty()}} sequence is used, so the number of actual labels may be different than \code{n.x}.} + +\item{n.y}{Preferred number of grid lines for the y axis. For the labels, a +\code{\link[=pretty]{pretty()}} sequence is used, so the number of actual labels may be different than \code{n.y}.} + +\item{crs}{Projection character. If specified, the grid lines are projected +accordingly. Many world maps are projected, but still have latitude longitude +(EPSG 4326) grid lines.} + +\item{labels.format}{List of formatting options for the grid labels. Parameters are: +\describe{ +\item{fun}{Function to specify the labels. It should take a numeric vector, +and should return a character vector of the same size. +By default it is not specified. If specified, the list items \code{scientific}, +\code{format}, and \code{digits} (see below) are not used.} +\item{scientific}{Should the labels be formatted scientifically? +If so, square brackets are used, and the \code{format} of the numbers is \code{"g"}. +Otherwise, \code{format="f"}, and \code{text.separator}, \code{text.less.than}, and +\code{text.or.more} are used. Also, the numbers are automatically rounded to +millions or billions if applicable.} +\item{format}{By default, \code{"f"}, i.e. the standard notation \code{xxx.xxx}, is used. +If \code{scientific=TRUE} then \code{"g"}, which means that numbers are formatted scientifically, +i.e. \code{n.dddE+nn} if needed to save space.} +\item{digits}{Number of digits after the decimal point if \code{format="f"}, and +the number of significant digits otherwise.} +\item{...}{Other arguments passed on to \code{\link[=formatC]{formatC()}}} +}} + +\item{labels.cardinal}{Add the four cardinal directions (N, E, S, W) to the labels, +instead of using negative coordinates for west and south (so it assumes that +the coordinates are positive in the north-east direction).} + +\item{...}{ + Arguments passed on to \code{\link[=tm_grid]{tm_grid}} + \describe{ + \item{\code{col}}{Color of the grid lines.} + \item{\code{lwd}}{Line width of the grid lines} + \item{\code{alpha}}{Alpha transparency of the grid lines. Number between 0 and 1. +By default, the alpha transparency of \code{col} is taken.} + \item{\code{labels.show}}{Show tick labels. Either one value for both \code{x} and \code{y} axis, +or a vector two: the first for \code{x} and latter for \code{y}.} + \item{\code{labels.pos}}{position of the labels. Vector of two: the horizontal +("left" or "right") and the vertical ("top" or "bottom") position.} + \item{\code{labels.size}}{Font size of the tick labels} + \item{\code{labels.col}}{Font color of the tick labels} + \item{\code{labels.rot}}{Rotation angles of the labels. Vector of two values: the +first is the rotation angle (in degrees) of the tick labels on the x axis +and the second is the rotation angle of the tick labels on the y axis. +Only \code{0}, \code{90}, \code{180}, and \code{270} are valid values.} + \item{\code{labels.margin.x}}{Margin between tick labels of x axis and the frame. +Note that when \code{labels.inside.frame = FALSE} and \code{ticks = TRUE}, +the ticks will be adjusted accordingly.} + \item{\code{labels.margin.y}}{Margin between tick labels of y axis and the frame. +Note that when \code{labels.inside.frame = FALSE} and \code{ticks = TRUE}, +the ticks will be adjusted accordingly.} + \item{\code{labels.space.x}}{Space that is used for the labels and ticks for the x-axis +when \code{labels.inside.frame = FALSE}. By default, it is determined automatically +using the widths and heights of the tick labels. The unit of this parameter is text line height.} + \item{\code{labels.space.y}}{Space that is used for the labels and ticks for the y-axis +when \code{labels.inside.frame = FALSE}. By default, it is determined automatically +using the widths and heights of the tick labels. The unit of this parameter is text line height.} + \item{\code{labels.inside.frame}}{Show labels inside the frame? By default \code{FALSE}.} + \item{\code{ticks}}{If \code{labels.inside.frame = FALSE}, should ticks can be drawn between the labels and the frame? +Either one value for both \code{x} and \code{y} axis, or a vector two: the first for \code{x} and latter for \code{y}.} + \item{\code{lines}}{If \code{labels.inside.frame = FALSE}, should grid lines can be drawn?} + \item{\code{ndiscr}}{Number of points to discretize a parallel or meridian +(only applicable for curved grid lines)} + \item{\code{zindex}}{zindex of the pane in view mode. By default, it is set to the +layer number plus 400. By default, the tmap layers will therefore be placed +in the custom panes \code{"tmap401"}, \code{"tmap402"}, etc., except for the base tile +layers, which are placed in the standard \code{"tile"}. This parameter determines +both the name of the pane and the z-index, which determines the pane order +from bottom to top. For instance, if \code{zindex} is set to 500, +the pane will be named \code{"tmap500"}.} + \item{\code{group}}{Name of the group to which this layer belongs. +This is only relevant in view mode, where layer groups can be +switched (see \code{group.control})} + \item{\code{group.control}}{In view mode, the group control determines how layer groups +can be switched on and off. Options: \code{"radio"} for radio buttons (meaning only one group can be shown), +\code{"check"} for check boxes (so multiple groups can be shown), and \code{"none"} +for no control (the group cannot be (de)selected).} + }} +} +\description{ +Draw latitude and longitude graticules. It creates a \code{\link{tmap-element}} that draws coordinate grid lines. It serves as a +layer that can be drawn anywhere between other layers. See \code{\link[=tm_grid]{tm_grid()}} for +drawing horizontal lines. +} +\examples{ +current.mode <- tmap_mode("plot") + +tm_shape(NLD_muni) + + tm_polygons() + + tm_grid() + +tm_shape(NLD_muni) + + tm_polygons() + + tm_grid(crs = 4326) + +tm_shape(NLD_muni) + + tm_polygons() + + tm_grid(crs = 3035, labels.inside.frame = TRUE) + +tm_shape(World) + + tm_polygons() + + tm_facets(by = "continent") + + tm_grid(labels.inside.frame = TRUE) + +tm_shape(NLD_muni) + + tm_polygons() + + tm_graticules() + +tm_shape(NLD_muni) + + tm_polygons() + + tm_graticules(labels.pos = c("right", "top")) + + +data(NLD_muni, World) + +tmap_arrange( + qtm(NLD_muni, borders = NULL) + tm_grid(), + qtm(NLD_muni, borders = NULL) + tm_graticules() +) + +qtm(World, shape.crs = "+proj=robin", style = "natural") + + tm_graticules(ticks = FALSE) + + tm_layout(frame=FALSE) + +tmap_mode(current.mode) +} diff --git a/man/tm_grid.Rd b/man/tm_grid.Rd index fd45bbdf..6feca110 100644 --- a/man/tm_grid.Rd +++ b/man/tm_grid.Rd @@ -1,21 +1,9 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tm_layers_aux.R -\name{tm_graticules} -\alias{tm_graticules} +\name{tm_grid} \alias{tm_grid} \title{Coordinate grid / graticule lines} \usage{ -tm_graticules( - x = NA, - y = NA, - n.x = NA, - n.y = NA, - crs = 4326, - labels.format = list(suffix = intToUtf8(176)), - labels.cardinal = TRUE, - ... -) - tm_grid( x = NA, y = NA, @@ -63,6 +51,28 @@ a \code{\link[=pretty]{pretty()}} sequence is used, so the number of actual labe accordingly. Many world maps are projected, but still have latitude longitude (EPSG 4326) grid lines.} +\item{col}{Color of the grid lines.} + +\item{lwd}{Line width of the grid lines} + +\item{alpha}{Alpha transparency of the grid lines. Number between 0 and 1. +By default, the alpha transparency of \code{col} is taken.} + +\item{labels.show}{Show tick labels. Either one value for both \code{x} and \code{y} axis, +or a vector two: the first for \code{x} and latter for \code{y}.} + +\item{labels.pos}{position of the labels. Vector of two: the horizontal +("left" or "right") and the vertical ("top" or "bottom") position.} + +\item{labels.size}{Font size of the tick labels} + +\item{labels.col}{Font color of the tick labels} + +\item{labels.rot}{Rotation angles of the labels. Vector of two values: the +first is the rotation angle (in degrees) of the tick labels on the x axis +and the second is the rotation angle of the tick labels on the y axis. +Only \code{0}, \code{90}, \code{180}, and \code{270} are valid values.} + \item{labels.format}{List of formatting options for the grid labels. Parameters are: \describe{ \item{fun}{Function to specify the labels. It should take a numeric vector, @@ -86,44 +96,20 @@ the number of significant digits otherwise.} instead of using negative coordinates for west and south (so it assumes that the coordinates are positive in the north-east direction).} -\item{...}{Arguments passed on to \code{\link[=tm_grid]{tm_grid()}}} - -\item{col}{Color of the grid lines.} - -\item{lwd}{Line width of the grid lines} - -\item{alpha}{Alpha transparency of the grid lines. Number between 0 and 1. -By default, the alpha transparency of \code{col} is taken.} - -\item{labels.show}{Show tick labels. Either one value for both \code{x} and \code{y} axis, -or a vector two: the first for \code{x} and latter for \code{y}.} - -\item{labels.pos}{position of the labels. Vector of two: the horizontal -("left" or "right") and the vertical ("top" or "bottom") position.} - -\item{labels.size}{Font size of the tick labels} - -\item{labels.col}{Font color of the tick labels} - -\item{labels.rot}{Rotation angles of the labels. Vector of two values: the -first is the rotation angle (in degrees) of the tick labels on the x axis -and the second is the rotation angle of the tick labels on the y axis. -Only \code{0}, \code{90}, \code{180}, and \code{270} are valid values.} - \item{labels.margin.x}{Margin between tick labels of x axis and the frame. -Note that when \code{labels.inside.frame == FALSE} and \code{ticks == TRUE}, +Note that when \code{labels.inside.frame = FALSE} and \code{ticks = TRUE}, the ticks will be adjusted accordingly.} \item{labels.margin.y}{Margin between tick labels of y axis and the frame. -Note that when \code{labels.inside.frame == FALSE} and \code{ticks == TRUE}, +Note that when \code{labels.inside.frame = FALSE} and \code{ticks = TRUE}, the ticks will be adjusted accordingly.} \item{labels.space.x}{Space that is used for the labels and ticks for the x-axis -when \code{labels.inside.frame == FALSE}. By default, it is determined automatically +when \code{labels.inside.frame = FALSE}. By default, it is determined automatically using the widths and heights of the tick labels. The unit of this parameter is text line height.} \item{labels.space.y}{Space that is used for the labels and ticks for the y-axis -when \code{labels.inside.frame == FALSE}. By default, it is determined automatically +when \code{labels.inside.frame = FALSE}. By default, it is determined automatically using the widths and heights of the tick labels. The unit of this parameter is text line height.} \item{labels.inside.frame}{Show labels inside the frame? By default \code{FALSE}.} @@ -152,13 +138,18 @@ switched (see \code{group.control})} can be switched on and off. Options: \code{"radio"} for radio buttons (meaning only one group can be shown), \code{"check"} for check boxes (so multiple groups can be shown), and \code{"none"} for no control (the group cannot be (de)selected).} + +\item{...}{Used to catch deprecated arguments from tmap v3.} } \description{ +\itemize{ +\item \code{tm_grid()} draws horizontal and vertical lines according to the +coordinate system of the (master) shape object. +} + Creates a \code{\link{tmap-element}} that draws coordinate grid lines. It serves as a -layer that can be drawn anywhere between other layers. -By default, \code{tm_grid()} draws horizontal and vertical lines according to the -coordinate system of the (master) shape object. Latitude and longitude -graticules are drawn with \code{tm_graticules()}. +layer that can be drawn anywhere between other layers. See \code{\link[=tm_graticules]{tm_graticules()}} +to draw latitude and longitude graticules. } \examples{ current.mode <- tmap_mode("plot") From ffb74fbf905f7125f42ac8c7394fbf652568cf48 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 8 Feb 2024 09:07:39 -0500 Subject: [PATCH 2/4] Simplify print docs --- R/print.R | 3 --- R/tm_element.R | 7 +------ man/print.tm_element.Rd | 1 + man/print.tmap.Rd | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/R/print.R b/R/print.R index c9a27386..eaf2222f 100644 --- a/R/print.R +++ b/R/print.R @@ -1,14 +1,11 @@ #' Draw thematic map #' -#' Draw thematic map. -#' #' @param x tmap object. #' @param return.asp should the aspect ratio be returned? #' @param show show the map #' @param vp viewport (for `"plot"` mode) #' @param ... not used #' @export -#' @method print tmap print.tmap = function(x, return.asp = FALSE, show = TRUE, vp = NULL, ...) { dev = getOption("tmap.devel.mode") if (dev) timing_init() diff --git a/R/tm_element.R b/R/tm_element.R index 6c35494c..dfbd9064 100644 --- a/R/tm_element.R +++ b/R/tm_element.R @@ -82,24 +82,19 @@ replace_last_tmap_by_correct_call = function(mc, lt) { -#' Print tm_element -#' #' Print tm_element #' #' @param x x #' @param ... passed on #' @export -#' @method print tm_element -#' @rdname print.tm_element #' @name print.tm_element +#' @keywords internal print.tm_element = function(x, ...) { cat("tm_element object\n") str(x, 2) } #' @rdname print.tm_element -#' @name print.tm_shape -#' @method print tm_shape #' @export print.tm_shape = function(x, ...) { NextMethod() diff --git a/man/print.tm_element.Rd b/man/print.tm_element.Rd index f2383bce..8a5229ad 100644 --- a/man/print.tm_element.Rd +++ b/man/print.tm_element.Rd @@ -17,3 +17,4 @@ \description{ Print tm_element } +\keyword{internal} diff --git a/man/print.tmap.Rd b/man/print.tmap.Rd index b2ced4c9..9015bd53 100644 --- a/man/print.tmap.Rd +++ b/man/print.tmap.Rd @@ -18,5 +18,5 @@ \item{...}{not used} } \description{ -Draw thematic map. +Draw thematic map } From 34a9cb4b82ddd90772b3a06c04239990751ac5b3 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 8 Feb 2024 09:08:29 -0500 Subject: [PATCH 3/4] Update docs for tm_title() --- R/tm_components.R | 20 ++++++++------------ man/tm_title.Rd | 16 +++++++--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/R/tm_components.R b/R/tm_components.R index 50dfc497..22a47cff 100644 --- a/R/tm_components.R +++ b/R/tm_components.R @@ -4,26 +4,23 @@ #' #' @param text text of the title #' @param size font size of the title -#' @param color color +#' @param color font color of the title #' @param padding padding -#' @param fontface font face +#' @param fontface font face, bold, italic #' @param fontfamily font family #' @param stack stack #' @param just just #' @param frame frame -#' @param frame.lwd frame.lwd +#' @param frame.lwd frame line width #' @param frame.r frame.r -#' @param bg.color bg.color -#' @param bg.alpha bg.alpha +#' @param bg.color Background color +#' @param bg.alpha Background transparency #' @param position position -#' @param width width -#' @param height height +#' @param width,height width and height of the title box. #' @param group.frame group.frame #' @param resize.as.group resize.as.group #' @param z z #' @export -#' @rdname tm_title -#' @name tm_title tm_title = function(text, size, color, padding, fontface, fontfamily, stack, just, frame, frame.lwd, frame.r, bg.color, bg.alpha, position, width, height, group.frame, resize.as.group, z) { args = lapply(as.list(match.call()[-1]), eval, envir = parent.frame()) if (!("z" %in% names(args))) args$z = as.integer(NA) @@ -31,9 +28,8 @@ tm_title = function(text, size, color, padding, fontface, fontfamily, stack, jus } #' @export -#' @param ... passed on to tm_title +#' @param ... passed on to `tm_title()` #' @rdname tm_title -#' @name tm_title_in tm_title_in = function(text, ..., position = tm_pos_in("left", "top")) { args = lapply(as.list(match.call()[-1]), eval, envir = parent.frame()) if (!("z" %in% names(args))) args$z = as.integer(NA) @@ -199,7 +195,7 @@ tm_scalebar = function(breaks, #' @inheritDotParams tm_scalebar #' @export tm_scale_bar = function(...) { - warning("As of version 4.0, tm_scale_bar has been renamed to tm_scalebar and is therefore deprecated", call. = FALSE) + warning("As of version 4.0, 'tm_scale_bar()' is deprecated. Please use 'tm_scalebar()' instead.", call. = FALSE) tm_scalebar(...) # can also be # stop("As of version 4.0, tm_scale_bar has been renamed to tm_scalebar and is therefore deprecated. tm_scalebar also has new argument names.", call. = FALSE) diff --git a/man/tm_title.Rd b/man/tm_title.Rd index f39ff796..b32cf15f 100644 --- a/man/tm_title.Rd +++ b/man/tm_title.Rd @@ -37,11 +37,11 @@ tm_title_out(text, ..., position = tm_pos_out("center", "top")) \item{size}{font size of the title} -\item{color}{color} +\item{color}{font color of the title} \item{padding}{padding} -\item{fontface}{font face} +\item{fontface}{font face, bold, italic} \item{fontfamily}{font family} @@ -51,19 +51,17 @@ tm_title_out(text, ..., position = tm_pos_out("center", "top")) \item{frame}{frame} -\item{frame.lwd}{frame.lwd} +\item{frame.lwd}{frame line width} \item{frame.r}{frame.r} -\item{bg.color}{bg.color} +\item{bg.color}{Background color} -\item{bg.alpha}{bg.alpha} +\item{bg.alpha}{Background transparency} \item{position}{position} -\item{width}{width} - -\item{height}{height} +\item{width, height}{width and height of the title box.} \item{group.frame}{group.frame} @@ -71,7 +69,7 @@ tm_title_out(text, ..., position = tm_pos_out("center", "top")) \item{z}{z} -\item{...}{passed on to tm_title} +\item{...}{passed on to \code{tm_title()}} } \description{ Map component that adds a title From 2f10429404a6eb344e4d262da9c2c77b2afc1cac Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 8 Feb 2024 09:09:08 -0500 Subject: [PATCH 4/4] Remove unnecessary `@method`. roxygen2 knows how to parse them. --- NAMESPACE | 3 +++ R/tmapGetShapeMeta.R | 11 ----------- R/tmapGridComp.R | 23 +---------------------- R/tmapGridComp_leg_landscape.R | 4 ---- R/tmapGridComp_leg_portrait.R | 4 ---- R/tmapLeafletComp.R | 20 -------------------- R/tmapLeafletComp_leg_portrait.R | 6 ------ R/tmapShape.R | 7 ------- R/tmapSplitShp.R | 2 -- R/tmapSubsetShp.R | 6 ------ R/tmap_arrange.R | 1 - 11 files changed, 4 insertions(+), 83 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index cf657b56..5bd667c4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,6 +31,7 @@ S3method(tmapGridCompHeight,tm_scalebar) S3method(tmapGridCompHeight,tm_title) S3method(tmapGridCompPrepare,tm_compass) S3method(tmapGridCompPrepare,tm_credits) +S3method(tmapGridCompPrepare,tm_legend_standard_landscape) S3method(tmapGridCompPrepare,tm_legend_standard_portrait) S3method(tmapGridCompPrepare,tm_mouse_coordinates) S3method(tmapGridCompPrepare,tm_scalebar) @@ -82,10 +83,12 @@ S3method(tmapReproject,sfc) S3method(tmapReproject,stars) S3method(tmapShape,Raster) S3method(tmapShape,SpatRaster) +S3method(tmapShape,SpatVector) S3method(tmapShape,sf) S3method(tmapShape,stars) S3method(tmapSplitShp,default) S3method(tmapSplitShp,stars) +S3method(tmapSubsetShp,Raster) S3method(tmapSubsetShp,SpatRaster) S3method(tmapSubsetShp,SpatVector) S3method(tmapSubsetShp,sf) diff --git a/R/tmapGetShapeMeta.R b/R/tmapGetShapeMeta.R index 6c86b757..62cea6d1 100644 --- a/R/tmapGetShapeMeta.R +++ b/R/tmapGetShapeMeta.R @@ -24,7 +24,6 @@ tmapGetShapeMeta2 = function(shp, smeta, o) { } -#' @method tmapGetShapeMeta1 stars #' @export tmapGetShapeMeta1.stars = function(shp, o) { d = stars::st_dimensions(shp) @@ -54,14 +53,12 @@ tmapGetShapeMeta1.stars = function(shp, o) { dims_vals = dims_vals) } -#' @method tmapGetShapeMeta1 Raster #' @export tmapGetShapeMeta1.Raster = function(shp, o) { tmapGetShapeMeta1.SpatRaster(terra::rast(shp), o) } -#' @method tmapGetShapeMeta2 stars #' @export tmapGetShapeMeta2.stars = function(shp, smeta, o) { smeta$vars_levs = lapply(seq_len(length(shp)), function(i) { @@ -72,7 +69,6 @@ tmapGetShapeMeta2.stars = function(shp, smeta, o) { } -#' @method tmapGetShapeMeta2 SpatRaster #' @export tmapGetShapeMeta2.SpatRaster = function(shp, smeta, o) { if (terra::ncell(shp) > o$raster.max.cells) { @@ -88,7 +84,6 @@ tmapGetShapeMeta2.SpatRaster = function(shp, smeta, o) { smeta } -#' @method tmapGetShapeMeta2 SpatVector #' @export tmapGetShapeMeta2.SpatVector = function(shp, smeta, o) { @@ -101,7 +96,6 @@ tmapGetShapeMeta2.SpatVector = function(shp, smeta, o) { } -#' @method tmapGetShapeMeta2 sf #' @export tmapGetShapeMeta2.sf = function(shp, smeta, o) { vars = setdiff(names(shp), attr(shp, "sf_column")) @@ -113,7 +107,6 @@ tmapGetShapeMeta2.sf = function(shp, smeta, o) { } -#' @method tmapGetShapeMeta1 sf #' @export tmapGetShapeMeta1.sf = function(shp, o) { vars = setdiff(names(shp), attr(shp, "sf_column")) @@ -128,7 +121,6 @@ tmapGetShapeMeta1.sf = function(shp, o) { } -#' @method tmapGetShapeMeta2 sfc #' @export tmapGetShapeMeta2.sfc = function(shp, smeta, o) { vars = character(0) @@ -137,7 +129,6 @@ tmapGetShapeMeta2.sfc = function(shp, smeta, o) { } -#' @method tmapGetShapeMeta1 sfc #' @export tmapGetShapeMeta1.sfc = function(shp, o) { vars = character(0) @@ -153,7 +144,6 @@ tmapGetShapeMeta1.sfc = function(shp, o) { -#' @method tmapGetShapeMeta1 SpatRaster #' @export tmapGetShapeMeta1.SpatRaster = function(shp, o) { vars = names(shp) @@ -168,7 +158,6 @@ tmapGetShapeMeta1.SpatRaster = function(shp, o) { } -#' @method tmapGetShapeMeta1 SpatVector #' @export tmapGetShapeMeta1.SpatVector = function(shp, o) { vars = names(shp) diff --git a/R/tmapGridComp.R b/R/tmapGridComp.R index fdae5ddc..6bb5a95a 100644 --- a/R/tmapGridComp.R +++ b/R/tmapGridComp.R @@ -24,55 +24,46 @@ tmapGridCompPrepare_text = function(comp, o) { } -#' @method tmapGridCompPrepare tm_title #' @export tmapGridCompPrepare.tm_title = function(comp, o) { tmapGridCompPrepare_text(comp, o) } -#' @method tmapGridCompHeight tm_title #' @export tmapGridCompHeight.tm_title = function(comp, o) { tmapGridCompHeight_text(comp, o) } -#' @method tmapGridCompWidth tm_title #' @export tmapGridCompWidth.tm_title = function(comp, o) { tmapGridCompWidth_text(comp, o) } -#' @method tmapGridLegPlot tm_title #' @export tmapGridLegPlot.tm_title = function(comp, o, fH, fW) { tmapGridLegPlot_text(comp, o) } -#' @method tmapGridCompPrepare tm_credits #' @export tmapGridCompPrepare.tm_credits = function(comp, o) { tmapGridCompPrepare_text(comp, o) } -#' @method tmapGridCompHeight tm_credits #' @export tmapGridCompHeight.tm_credits = function(comp, o) { tmapGridCompHeight_text(comp, o) } -#' @method tmapGridCompWidth tm_credits #' @export tmapGridCompWidth.tm_credits = function(comp, o) { tmapGridCompWidth_text(comp, o) } -#' @method tmapGridLegPlot tm_credits #' @export tmapGridLegPlot.tm_credits = function(comp, o, fH, fW) { tmapGridLegPlot_text(comp, o, fH, fW) } -#' @method tmapGridCompPrepare tm_compass #' @export tmapGridCompPrepare.tm_compass = function(comp, o) { o$attr.color.light = is_light(o$attr.color) @@ -95,7 +86,6 @@ tmapGridCompPrepare.tm_compass = function(comp, o) { }) } -#' @method tmapGridCompHeight tm_compass #' @export tmapGridCompHeight.tm_compass = function(comp, o) { @@ -118,7 +108,6 @@ tmapGridCompHeight.tm_compass = function(comp, o) { comp } -#' @method tmapGridCompWidth tm_compass #' @export tmapGridCompWidth.tm_compass = function(comp, o) { @@ -138,7 +127,6 @@ tmapGridCompWidth.tm_compass = function(comp, o) { comp } -#' @method tmapGridLegPlot tm_compass #' @export tmapGridLegPlot.tm_compass = function(comp, o, fH, fW) { u = 1/(comp$nlines) @@ -325,7 +313,6 @@ tmapGridLegPlot.tm_compass = function(comp, o, fH, fW) { -#' @method tmapGridCompPrepare tm_scalebar #' @export tmapGridCompPrepare.tm_scalebar = function(comp, o) { show.messages = o$show.messages @@ -333,7 +320,7 @@ tmapGridCompPrepare.tm_scalebar = function(comp, o) { within(comp, { if (is.function(call)) call = "" if (all(c("breaks", "width") %in% call) && show.warnings) { - warning("For tm_scalebar, breaks and width cannot be used together. The width is being ignored.", call. = FALSE) + warning("For 'tm_scalebar()', 'breaks' and 'width' cannot be used together. The width is being ignored.", call. = FALSE) } if ("breaks" %in% call) { if (breaks[1] != 0) { @@ -356,7 +343,6 @@ tmapGridCompPrepare.tm_scalebar = function(comp, o) { }) } -#' @method tmapGridCompHeight tm_scalebar #' @export tmapGridCompHeight.tm_scalebar = function(comp, o) { h = 2.75 * o$lin * comp$text.size @@ -379,7 +365,6 @@ tmapGridCompHeight.tm_scalebar = function(comp, o) { comp } -#' @method tmapGridCompWidth tm_scalebar #' @export tmapGridCompWidth.tm_scalebar = function(comp, o) { #w = comp$width * o$lin * comp$text.size @@ -409,7 +394,6 @@ tmapGridCompWidth.tm_scalebar = function(comp, o) { comp } -#' @method tmapGridLegPlot tm_scalebar #' @export tmapGridLegPlot.tm_scalebar = function(comp, o, fH, fW) { light = do.call("process_color", c(list(comp$color.light, alpha=1), o$pc)) @@ -663,7 +647,6 @@ tmapGridCompWidth_text = function(comp, o) { } -#' @method tmapGridCompPrepare tm_mouse_coordinates #' @export tmapGridCompPrepare.tm_mouse_coordinates = function(comp, o) { message("tm_mouse_coordinates ignored for 'plot' mode") @@ -672,20 +655,16 @@ tmapGridCompPrepare.tm_mouse_coordinates = function(comp, o) { } -#' @method tmapGridCompHeight tm_mouse_coordinates #' @export tmapGridCompHeight.tm_mouse_coordinates = function(comp, o) { comp } -#' @method tmapGridCompWidth tm_mouse_coordinates #' @export tmapGridCompWidth.tm_mouse_coordinates = function(comp, o) { comp } - -#' @method tmapGridLegPlot tm_mouse_coordinates #' @export tmapGridLegPlot.tm_mouse_coordinates = function(comp, o, fH, fW) { NULL diff --git a/R/tmapGridComp_leg_landscape.R b/R/tmapGridComp_leg_landscape.R index 0fde43d1..91255222 100644 --- a/R/tmapGridComp_leg_landscape.R +++ b/R/tmapGridComp_leg_landscape.R @@ -14,7 +14,6 @@ tmapGridLegPlot = function(comp, o, fH, fW) { UseMethod("tmapGridLegPlot") } -#' @method tmapGridCompPrepare tm_legend_standard_portrait #' @export tmapGridCompPrepare.tm_legend_standard_landscape = function(comp, o) { tmapGridCompPrepare.tm_legend_standard_portrait(comp, o) @@ -23,7 +22,6 @@ tmapGridCompPrepare.tm_legend_standard_landscape = function(comp, o) { -#' @method tmapGridCompHeight tm_legend_standard_landscape #' @export tmapGridCompHeight.tm_legend_standard_landscape = function(comp, o) { nlev = comp$nitems @@ -60,7 +58,6 @@ tmapGridCompHeight.tm_legend_standard_landscape = function(comp, o) { } -#' @method tmapGridCompWidth tm_legend_standard_landscape #' @export tmapGridCompWidth.tm_legend_standard_landscape = function(comp, o) { nlev = comp$nitems @@ -135,7 +132,6 @@ tmapGridCompWidth.tm_legend_standard_landscape = function(comp, o) { } -#' @method tmapGridLegPlot tm_legend_standard_landscape #' @export tmapGridLegPlot.tm_legend_standard_landscape = function(comp, o, fH, fW) { textS = comp$text.size * comp$scale diff --git a/R/tmapGridComp_leg_portrait.R b/R/tmapGridComp_leg_portrait.R index 152e4d3b..1d433b22 100644 --- a/R/tmapGridComp_leg_portrait.R +++ b/R/tmapGridComp_leg_portrait.R @@ -1,4 +1,3 @@ -#' @method tmapGridCompPrepare tm_legend_standard_portrait #' @export tmapGridCompPrepare.tm_legend_standard_portrait = function(comp, o) { within(comp, { @@ -29,7 +28,6 @@ tmapGridCompPrepare.tm_legend_standard_portrait = function(comp, o) { } -#' @method tmapGridCompHeight tm_legend_standard_portrait #' @export tmapGridCompHeight.tm_legend_standard_portrait = function(comp, o) { @@ -138,7 +136,6 @@ fontface2nr = function(face) { } -#' @method tmapGridCompWidth tm_legend_standard_portrait #' @export tmapGridCompWidth.tm_legend_standard_portrait = function(comp, o) { @@ -223,7 +220,6 @@ tmapGridCompWidth.tm_legend_standard_portrait = function(comp, o) { } -#' @method tmapGridLegPlot tm_legend_standard_portrait #' @export tmapGridLegPlot.tm_legend_standard_portrait = function(comp, o, fH, fW) { textS = comp$text.size * comp$scale #* o$scale diff --git a/R/tmapLeafletComp.R b/R/tmapLeafletComp.R index 4780dac0..80823ee2 100644 --- a/R/tmapLeafletComp.R +++ b/R/tmapLeafletComp.R @@ -1,5 +1,4 @@ -#' @method tmapLeafletCompPrepare tm_title #' @export tmapLeafletCompPrepare.tm_title = function(comp, o) { comp$show = TRUE @@ -7,20 +6,17 @@ tmapLeafletCompPrepare.tm_title = function(comp, o) { } -#' @method tmapLeafletCompHeight tm_title #' @export tmapLeafletCompHeight.tm_title = function(comp, o) { comp } -#' @method tmapLeafletCompWidth tm_title #' @export tmapLeafletCompWidth.tm_title = function(comp, o) { comp } -#' @method tmapLeafletLegPlot tm_title #' @export tmapLeafletLegPlot.tm_title = function(comp, lf, o) { if (inherits(lf, "shiny.tag.list")) { @@ -60,7 +56,6 @@ tmapLeafletLegPlot.tm_title = function(comp, lf, o) { -#' @method tmapLeafletCompPrepare tm_compass #' @export tmapLeafletCompPrepare.tm_compass = function(comp, o) { comp$show = TRUE @@ -68,20 +63,17 @@ tmapLeafletCompPrepare.tm_compass = function(comp, o) { } -#' @method tmapLeafletCompHeight tm_compass #' @export tmapLeafletCompHeight.tm_compass = function(comp, o) { comp } -#' @method tmapLeafletCompWidth tm_compass #' @export tmapLeafletCompWidth.tm_compass = function(comp, o) { comp } -#' @method tmapLeafletLegPlot tm_compass #' @export tmapLeafletLegPlot.tm_compass = function(comp, lf, o) { lf %>% leafem::addLogo(system.file(paste0("img/compass_", comp$type, ".png"), package = "tmap"), src = "local", position = leaflet_pos(comp$position), width = 120, height = 120) @@ -89,7 +81,6 @@ tmapLeafletLegPlot.tm_compass = function(comp, lf, o) { -#' @method tmapLeafletCompPrepare tm_scalebar #' @export tmapLeafletCompPrepare.tm_scalebar = function(comp, o) { comp$show = TRUE @@ -97,20 +88,17 @@ tmapLeafletCompPrepare.tm_scalebar = function(comp, o) { } -#' @method tmapLeafletCompHeight tm_scalebar #' @export tmapLeafletCompHeight.tm_scalebar = function(comp, o) { comp } -#' @method tmapLeafletCompWidth tm_scalebar #' @export tmapLeafletCompWidth.tm_scalebar = function(comp, o) { comp } -#' @method tmapLeafletLegPlot tm_scalebar #' @export tmapLeafletLegPlot.tm_scalebar = function(comp, lf, o) { lf %>% leaflet::addScaleBar(position = leaflet_pos(comp$position)) @@ -119,27 +107,23 @@ tmapLeafletLegPlot.tm_scalebar = function(comp, lf, o) { -#' @method tmapLeafletCompPrepare tm_credits #' @export tmapLeafletCompPrepare.tm_credits = function(comp, o) { comp } -#' @method tmapLeafletCompHeight tm_credits #' @export tmapLeafletCompHeight.tm_credits = function(comp, o) { comp } -#' @method tmapLeafletCompWidth tm_credits #' @export tmapLeafletCompWidth.tm_credits = function(comp, o) { comp } -#' @method tmapLeafletLegPlot tm_credits #' @export tmapLeafletLegPlot.tm_credits = function(comp, lf, o) { #lf %>% leafem::addLogo(system.file(paste0("img/credits_", comp$type, ".png"), package = "tmap"), src = "local", position = paste(unlist(comp$position[c("pos.v", "pos.h")]), collapse = ""), width = 120, height = 120) @@ -148,7 +132,6 @@ tmapLeafletLegPlot.tm_credits = function(comp, lf, o) { } -#' @method tmapLeafletCompPrepare tm_mouse_coordinates #' @export tmapLeafletCompPrepare.tm_mouse_coordinates = function(comp, o) { comp$show = TRUE @@ -156,20 +139,17 @@ tmapLeafletCompPrepare.tm_mouse_coordinates = function(comp, o) { } -#' @method tmapLeafletCompHeight tm_mouse_coordinates #' @export tmapLeafletCompHeight.tm_mouse_coordinates = function(comp, o) { comp } -#' @method tmapLeafletCompWidth tm_mouse_coordinates #' @export tmapLeafletCompWidth.tm_mouse_coordinates = function(comp, o) { comp } -#' @method tmapLeafletLegPlot tm_mouse_coordinates #' @export tmapLeafletLegPlot.tm_mouse_coordinates = function(comp, lf, o) { lf %>% leafem::addMouseCoordinates() diff --git a/R/tmapLeafletComp_leg_portrait.R b/R/tmapLeafletComp_leg_portrait.R index 1973b263..4e4277a2 100644 --- a/R/tmapLeafletComp_leg_portrait.R +++ b/R/tmapLeafletComp_leg_portrait.R @@ -15,7 +15,6 @@ tmapLeafletLegPlot = function(comp, lf, o) { } -#' @method tmapLeafletCompPrepare tm_legend_standard_portrait #' @export tmapLeafletCompPrepare.tm_legend_standard_portrait = function(comp, o) { tmapLeaflet_legend_comp(comp, o) @@ -55,7 +54,6 @@ tmapLeaflet_legend_comp = function(comp, o) { } -#' @method tmapLeafletCompHeight tm_legend_standard_portrait #' @export tmapLeafletCompHeight.tm_legend_standard_portrait = function(comp, o) { comp @@ -63,7 +61,6 @@ tmapLeafletCompHeight.tm_legend_standard_portrait = function(comp, o) { -#' @method tmapLeafletCompWidth tm_legend_standard_portrait #' @export tmapLeafletCompWidth.tm_legend_standard_portrait = function(comp, o) { comp @@ -73,13 +70,11 @@ tmapLeafletCompWidth.tm_legend_standard_portrait = function(comp, o) { -#' @method tmapLeafletCompPrepare tm_legend_standard_landscape #' @export tmapLeafletCompPrepare.tm_legend_standard_landscape = function(comp, o) { tmapLeaflet_legend_comp(comp, o) } -#' @method tmapLeafletCompHeight tm_legend_standard_landscape #' @export tmapLeafletCompHeight.tm_legend_standard_landscape = function(comp, o) { comp @@ -87,7 +82,6 @@ tmapLeafletCompHeight.tm_legend_standard_landscape = function(comp, o) { -#' @method tmapLeafletCompWidth tm_legend_standard_landscape #' @export tmapLeafletCompWidth.tm_legend_standard_landscape = function(comp, o) { comp diff --git a/R/tmapShape.R b/R/tmapShape.R index ea4b5d68..e054ca84 100644 --- a/R/tmapShape.R +++ b/R/tmapShape.R @@ -2,7 +2,6 @@ tmapReproject = function(...) { UseMethod("tmapReproject") } -#' @method tmapReproject stars #' @export tmapReproject.stars = function(shp, tmapID, bbox = NULL, ..., crs) { shp[[1]] = tmapID @@ -17,7 +16,6 @@ tmapReproject.stars = function(shp, tmapID, bbox = NULL, ..., crs) { } -#' @method tmapReproject dimensions #' @export tmapReproject.dimensions = function(shp, tmapID, bbox = NULL, ..., crs) { s = structure(list(tmapID = matrix(tmapID, nrow = nrow(shp))), dimensions = shp, class = "stars") @@ -37,7 +35,6 @@ tmapReproject.dimensions = function(shp, tmapID, bbox = NULL, ..., crs) { } -#' @method tmapReproject sfc #' @export tmapReproject.sfc = function(shp, tmapID, bbox = NULL, ..., crs) { if (is.na(sf::st_crs(shp))) { @@ -89,7 +86,6 @@ tmapShape.Raster = function(shp, is.main, crs, bbox, unit, filter, shp_name, sme } -#' @method tmapShape SpatRaster #' @export tmapShape.SpatRaster = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) { #tmapShape.stars(stars::st_as_stars(shp), is.main, crs, bbox, unit, filter, shp_name) @@ -172,7 +168,6 @@ tmapShape.SpatRaster = function(shp, is.main, crs, bbox, unit, filter, shp_name, -#' @method tmapShape SpatRaster #' @export tmapShape.SpatVector = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) { tmapShape.sf(sf::st_as_sf(shp), is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) @@ -216,7 +211,6 @@ make_by_vars = function(dt, tmf, smeta) { -#' @method tmapShape stars #' @export tmapShape.stars = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) { dev = getOption("tmap.devel.mode") @@ -332,7 +326,6 @@ tmapShape.stars = function(shp, is.main, crs, bbox, unit, filter, shp_name, smet } -#' @method tmapShape sf #' @export tmapShape.sf = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) { if (!is.null(crs) && sf::st_crs(shp) != crs) { diff --git a/R/tmapSplitShp.R b/R/tmapSplitShp.R index 6d221110..403e1ae5 100644 --- a/R/tmapSplitShp.R +++ b/R/tmapSplitShp.R @@ -11,7 +11,6 @@ tmapSplitShp = function(shp, split_stars_dim) { UseMethod("tmapSplitShp") } -#' @method tmapSplitShp stars #' @export tmapSplitShp.stars = function(shp, split_stars_dim) { if (split_stars_dim != "") { @@ -22,7 +21,6 @@ tmapSplitShp.stars = function(shp, split_stars_dim) { shp } -#' @method tmapSplitShp default #' @export tmapSplitShp.default = function(shp, split_stars_dim) { shp diff --git a/R/tmapSubsetShp.R b/R/tmapSubsetShp.R index 0564f9dc..0f6827e0 100644 --- a/R/tmapSubsetShp.R +++ b/R/tmapSubsetShp.R @@ -10,7 +10,6 @@ tmapSubsetShp = function(shp, vars) { UseMethod("tmapSubsetShp") } -#' @method tmapSubsetShp stars #' @export tmapSubsetShp.stars = function(shp, vars) { ids = unique(c(which(names(shp) %in% vars), @@ -22,7 +21,6 @@ tmapSubsetShp.stars = function(shp, vars) { shp2 } -#' @method tmapSubsetShp SpatRaster #' @export tmapSubsetShp.SpatRaster = function(shp, vars) { #v = setdiff(vars, names(shp)) @@ -34,13 +32,11 @@ tmapSubsetShp.SpatRaster = function(shp, vars) { } } -#' @method tmapSubsetShp SpatRaster #' @export tmapSubsetShp.Raster = function(shp, vars) { tmapSubsetShp.SpatRaster(terra::rast(shp), vars) } -#' @method tmapSubsetShp SpatVector #' @export tmapSubsetShp.SpatVector = function(shp, vars) { if ("AREA" %in% vars && !("AREA" %in% names(shp))) { @@ -53,7 +49,6 @@ tmapSubsetShp.SpatVector = function(shp, vars) { } -#' @method tmapSubsetShp sf #' @export tmapSubsetShp.sf = function(shp, vars) { @@ -73,7 +68,6 @@ tmapSubsetShp.sf = function(shp, vars) { shp[, vars] } -#' @method tmapSubsetShp sfc #' @export tmapSubsetShp.sfc = function(shp, vars) { s = sf::st_sf(dummy__ = TRUE, geometry = shp) diff --git a/R/tmap_arrange.R b/R/tmap_arrange.R index b9e199a4..05d219b1 100644 --- a/R/tmap_arrange.R +++ b/R/tmap_arrange.R @@ -60,7 +60,6 @@ knit_print.tmap_arrange <- function(x, ..., options = NULL) { #' @export #' @rdname tmap_arrange -#' @method print tmap_arrange print.tmap_arrange <- function(x, knit = FALSE, ..., options = NULL) { print_tmap_arrange(x, knit=knit, ..., options = options) }