Skip to content

Commit

Permalink
Pepper spray (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Jan 13, 2025
1 parent a62c002 commit b0a35d8
Show file tree
Hide file tree
Showing 35 changed files with 200 additions and 244 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ License: GPL-3
URL: https://github.com/r-tmap/tmap, https://r-tmap.github.io/tmap/
BugReports: https://github.com/r-tmap/tmap/issues
Depends:
R (>= 3.6.0)
R (>= 4.1)
Imports:
classInt (>= 0.4-3),
cli,
Expand Down
5 changes: 3 additions & 2 deletions R/tm_chart.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
#' @param breaks The breaks of the bins (for histograms)
#' @param plot.axis.x,plot.axis.y Should the x axis and y axis be plot?
#' @param extra.ggplot2 Extra ggplot2 code
#' @param position Position of the chart. See [tm_pos()] for details
#' @param position Position of the chart. An object created with `tm_pos_in()` or `tm_pos_out()`. Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is `"left"`, `"center"` or `"right"` (or upper case, meaning tighter to the map frame), the second `"top"`, `"center"` or `"bottom"`. Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also \href{vignette about positioning}{https://r-tmap.github.io/tmap/articles/adv_positions}.
#' @param width in number of text lines (height of it)
#' @param height in number of text lines
#' @param stack stack with other map components?
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @param z stacking order
#' @param group.frame group.frame
#' @param resize_as_group resize_as_group
#' @example examples/tm_chart.R
#' @seealso \href{Vignette about charts}{https://r-tmap.github.io/tmap/articles/basics_charts}
#' @name tm_chart
#' @export
tm_chart_histogram = function(breaks,
Expand Down
18 changes: 9 additions & 9 deletions R/tm_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#' @param fontface font face, bold, italic
#' @param fontfamily font family
#' @param alpha alpha transparency of the text
#' @param stack stack
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @param just just
#' @param frame frame
#' @param frame.lwd frame line width
#' @param frame.r Radius of the rounded frame corners. 0 means no rounding.
#' @param bg.color Background color
#' @param bg.alpha Background transparency
#' @param position Vector of two values, specifying the x and y coordinates. The first is either `"left"` or `"right"`, the second either `"top"` or `"bottom"`.
#' @param position An object created with `tm_pos_in()` or `tm_pos_out()`. Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is `"left"`, `"center"` or `"right"` (or upper case, meaning tighter to the map frame), the second `"top"`, `"center"` or `"bottom"`. Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also \href{vignette about positioning}{https://r-tmap.github.io/tmap/articles/adv_positions}.
#' @param width,height width and height of the text box.
#' @param group.frame group.frame
#' @param resize_as_group resize_as_group
Expand Down Expand Up @@ -83,7 +83,7 @@ tm_credits = function(text, size, color, padding, fontface, fontfamily, alpha, s
#' @param color.light color.light
#' @param lwd lwd
#' @inheritParams tm_title
#' @param stack stack
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @param just just
#' @param margins margins
#' @param ... to catch deprecated arguments (alpha)
Expand Down Expand Up @@ -127,7 +127,7 @@ tm_compass <- function(north,
#' @param lwd linewidth
#' @inheritParams tm_title
#' @param size Deprecated (use `text.size` instead)
#' @param stack stack
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @param margins margins
#' @export
tm_scalebar = function(breaks,
Expand Down Expand Up @@ -177,8 +177,8 @@ tm_scale_bar = function(...) {
#'
#' Map component that adds mouse coordinates
#'
#' @param stack stack
#' @param position position
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @param position position. An object created with `tm_pos_in()` or `tm_pos_out()`. Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is `"left"`, `"center"` or `"right"` (or upper case, meaning tighter to the map frame), the second `"top"`, `"center"` or `"bottom"`. Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also \href{vignette about positioning}{https://r-tmap.github.io/tmap/articles/adv_positions}.
#' @param z z
#' @export
tm_mouse_coordinates <- function(stack,
Expand All @@ -197,8 +197,8 @@ tm_mouse_coordinates <- function(stack,
#' By default, it shows the same map as the basemap, and moreover, it will automatically change when the user switches basemaps.
#' Note the latter does not happen when `server` is specified.
#' @param toggle should the minimap have a button to minimise it? By default \code{TRUE}.
#' @param position position of the minimap. Vector of two values, specifying the x and y coordinates. The first is either `"left"` or `"right"`, the second either `"top"` or `"bottom"`.
#' @param stack stack
#' @param position position of the minimap. An object created with `tm_pos_in()` or `tm_pos_out()`. Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is `"left"`, `"center"` or `"right"` (or upper case, meaning tighter to the map frame), the second `"top"`, `"center"` or `"bottom"`. Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also \href{vignette about positioning}{https://r-tmap.github.io/tmap/articles/adv_positions}.
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @param position position
#' @param z z
#' @inheritDotParams leaflet::addMiniMap
Expand All @@ -225,7 +225,7 @@ tm_minimap <- function(server,
#' If multiple logos are specified by a vector or list, the heights can be specified accordingly.
#' @param margins margins
#' @param between_margin Margin between
#' @param stack stack
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`.
#' @inheritParams tm_title
#' @param group.frame group.frame
#' @param resize_as_group resize_as_group
Expand Down
28 changes: 6 additions & 22 deletions R/tm_crs.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
#' Set the map projection (CRS)
#'
#' This function sets the map projection. It can also be set via [tm_shape()], but `tm_crs` is generally recommended. It can also be determined automatically (see details); however, this is still work-in-progress.
#' This function sets the map projection. It can also be set via [tm_shape()], but `tm_crs` is generally recommended for most cases. It can also be determined automatically (see details); however, this is still work-in-progress.
#'
#' @param crs Map projection (CRS). Can be set to an `crs` object (see [sf::st_crs()]), a proj4string, an EPSG number, or one the the following generic projections: `c("laea", "aeqd", "utm", "pconic", "eqdc", "stere")`. See details.
#' @param crs Map projection (CRS). Can be set to an `crs` object (see [sf::st_crs()]), a proj4string, an EPSG number, the value `"auto"` (automatic crs recommendation), or one the the following generic projections: `c("laea", "aeqd", "utm", "pconic", "eqdc", "stere")`. See details.
#' @param property Which property should the projection have? One of: `"global"`, `"area"` (equal-area), `"distance"` (equidistant), `"shape"` (conformal). Only applicable if `crs = "auto"`. See details.
#' @note Plans are to migrate the functionality regarding generic crs and automatic crs recommendation to a separate package.
#' @details
#' The automatic crs recommendation is following:
#'
#' | **Property** | **Recommendation** |
#' | ------ | ----------- |
#' | `global` (for world maps) | A pseudocylindrical projection tmap option `crs_global`, by default `"eqearth` (Equal Eearth). See \url{https://r-tmap.github.io/tmap/articles/41_advanced_crs.html} for more options|
#' | `area` (equal area) | Lambert Azimuthal Equal Area (`laea`) |
#' | `distance` (equidistant) | Azimuthal Equidistant (`aeqd`) |
#' | `shape` (conformal) | Stereographic (`stere`) |
#'
#' For further info about the available "generic" projects see:
#' for utm: \url{https://proj.org/en/9.4/operations/projections/utm.html}
#' for laea: \url{https://proj.org/en/9.4/operations/projections/laea.html}
#' for aeqd: \url{https://proj.org/en/9.4/operations/projections/aeqd.html}
#' for pconic: \url{https://proj.org/en/9.4/operations/projections/pconic.html}
#' for eqdc: \url{https://proj.org/en/9.4/operations/projections/eqdc.html}
#' @inherit tm_shape details
#' @example ./examples/tm_crs.R
#' @seealso \href{vignette about CRS}{https://r-tmap.github.io/tmap/articles/foundations_crs}
#' @export
tm_crs = function(crs = NA, property = NA) {
if (is.na(crs)) {
Expand Down Expand Up @@ -76,7 +62,7 @@ auto_crs = function(x, crs_extra, crs_global) {
consider_global(x)
}

if (is_global) {
y = if (is_global) {
crs_global
} else {
# impute family
Expand All @@ -88,9 +74,7 @@ auto_crs = function(x, crs_extra, crs_global) {
)
to_generic_projected(x, proj = proj, return_as = "crs")
}



sf::st_crs(y)
}


Expand Down
3 changes: 2 additions & 1 deletion R/tm_layers_aux.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' order in which this layer is called, just like other map layers.
#'
#' @param server Name of the provider or an URL. The list of available providers
#' can be obtained with `providers` (tip: in RStudio, type `providers$` to see
#' can be obtained with `providers` (tip: in RStudio, type `leaflet::providers$` to see
#' the options). See <https://leaflet-extras.github.io/leaflet-providers/preview/>
#' for a preview of those. When a URL is provided, it should be in template format,
#' e.g. \code{"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}.
Expand All @@ -30,6 +30,7 @@
#' (so multiple groups can be shown), and `"none"` for no control
#' (the group cannot be (de)selected).
#' @export
#' @seealso \href{Basemap examples}{https://r-tmap.github.io/tmap/articles/basics_basemaps}
#' @example ./examples/tm_basemap.R
tm_basemap = function(server = NA, alpha = NULL, zoom = NULL, max.native.zoom = 17, zindex = 0, group = NA, group.control = "radio") {
if (is.null(server)) {
Expand Down
1 change: 1 addition & 0 deletions R/tm_layers_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @inherit tm_polygons details
#' @param ... to catch deprecated arguments from version < 4.0
#' @example ./examples/tm_lines.R
#' @seealso \href{Terrain map example}{https://r-tmap.github.io/tmap/articles/examples_terrain}
#' @export
tm_lines = function(col = tm_const(),
col.scale = tm_scale(),
Expand Down
2 changes: 1 addition & 1 deletion R/tm_layers_polygons.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
#' features. Only used for `"view"` mode.
#' @param ... to catch deprecated arguments from version < 4.0
#' @example ./examples/tm_polygons.R
#' @seealso \href{Vignette about choropleth (1)}{https://r-tmap.github.io/tmap/articles/examples_choro_World} and \href{vignette about choropleth (2)}{https://r-tmap.github.io/tmap/articles/examples_choro_NLD}
#' @seealso \href{Choropleth example (1)}{https://r-tmap.github.io/tmap/articles/examples_choro_World} and \href{choropleth example (2)}{https://r-tmap.github.io/tmap/articles/examples_choro_NLD}
#' @export
tm_polygons = function(fill = tm_const(),
fill.scale = tm_scale(),
Expand Down
27 changes: 1 addition & 26 deletions R/tm_layers_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,13 @@
#'
#' Map layer that draws rasters. Supported visual variable is: `col` (the color).
#'
#' The visual variable arguments (e.g. `col`) can be specified with either a data
#' variable name (e.g., a spatial vector attribute or a raster layer of the object
#' specified in [tm_shape()]), or with a visual value (for `col`, a color is expected).
#' Multiple values can be specified: in that case facets are created.
#' These facets can be combined with other faceting data variables, specified with [tm_facets()].
#'
#' * The `*.scale` arguments determine the used scale to map the data values to
#' visual variable values. These can be specified with one of the available
#' `tm_scale_*()` functions. The default is specified by the tmap option ([tm_options()]) `scales.var`.
#'
#' * The `*.legend` arguments determine the used legend, specified with [tm_legend()].
#' The default legend and its settings are determined by the tmap options ([tm_options()]) `legend.` .
#'
#' * The `*.chart` arguments specify additional charts, specified with `tm_chart_`, e.g. [tm_chart_histogram()]
#'
#' * The `*.free` arguments determine whether scales are applied freely across facets, or shared.
#' A logical value is required. They can also be specified with a vector of three
#' logical values; these determine whether scales are applied freely per facet dimension.
#' This is only useful when facets are applied (see [tm_facets()]).
#' There are maximally three facet dimensions: rows, columns, and pages. This only
#' applies for a facet grid ([tm_facets_grid()]). For instance, `col.free = c(TRUE, FALSE, FALSE)`
#' means that for the visual variable `col`, each row of facets will have its own
#' scale, and therefore its own legend. For facet wraps and stacks
#' ([tm_facets_wrap()] and [tm_facets_stack()]) there is only one facet dimension,
#' so the `*.free` argument requires only one logical value.
#'
#' @param col,col.scale,col.legend,col.chart,col.free `r .doc_vv("col")`
#' @param col_alpha,col_alpha.scale,col_alpha.legend,col_alpha.chart,col_alpha.free `r .doc_vv("col_alpha")`
#' @inheritParams tm_polygons
#' @param options options passed on to the corresponding `opt_<layer_function>` function
#' @param ... to catch deprecated arguments from version < 4.0
#' @example ./examples/tm_raster.R
#' @inherit tm_polygons details
#' @export
tm_raster = function(col = tm_vars(),
col.scale = tm_scale(),
Expand Down
27 changes: 1 addition & 26 deletions R/tm_layers_sf.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
#' Map layer: simple features
#'
#' @description
#' Map layer that draws simple features as they are. Supported visual variables
#' are: `fill` (the fill color), `col` (the border color), `size` the point size,
#' `shape` the symbol shape, `lwd` (line width), `lty` (line type), `fill_alpha` (fill color alpha transparency)
#' and `col_alpha` (border color alpha transparency).
#'
#' The visual variable arguments (e.g. `col`) can be specified with either a data
#' variable name (of the object specified in [tm_shape()]), or with a visual value
#' (for `col`, a color is expected). Multiple values can be specified: in that case
#' facets are created. These facets can be combined with other faceting data variables,
#' specified with [tm_facets()].
#'
#' @details
#' The `.scale` arguments determine the used scale to map the data values to visual
#' variable values. These can be specified with one of the available `tm_scale_()` functions.
#' The default scale that is used is specified by the tmap option `scales.var`.
#'
#' The `.legend` arguments determine the used legend, specified with [tm_legend()].
#' The default legend and its settings are determined by the tmap options `legend.`.
#'
#' The `.free` arguments determine whether scales are applied freely across facets,
#' or shared. A logical value is required. They can also be specified with a
#' vector of three logical values; these determine whether scales are applied freely
#' per facet dimension. This is only useful when facets are applied (see [tm_facets()]).
#' There are maximally three facet dimensions: rows, columns, and pages. This only applies
#' for a facet grid ([tm_facets_grid()]). For instance, `col.free = c(TRUE, FALSE, FALSE)` means
#' that for the visual variable `col`, each row of facets will have its own scale,
#' and therefore its own legend. For facet wraps and stacks ([tm_facets_wrap()] and
#' [tm_facets_stack()]) there is only one facet dimension, so the `.free` argument requires
#' only one logical value.
#'
#' @param fill,fill.scale,fill.legend,fill.free `r .doc_vv("fill")`
#' @param col,col.scale,col.legend,col.free `r .doc_vv("col")`
#' @param size,size.scale,size.legend,size.free `r .doc_vv("size")`
Expand All @@ -44,6 +18,7 @@
#' This consists of a list of three elementary geometry types: for polygons, lines and, points.
#' For each of these types, which are drawn in that order, a [tm_plot_order()] is required.
#' @param options options passed on to the corresponding `opt_<layer_function>` function
#' @inherit tm_polygons details
#' @inheritParams tm_polygons
#' @param ... passed on to [tm_polygons()], [tm_lines()], and [tm_dots()]
#' @example ./examples/tm_sf.R
Expand Down
28 changes: 2 additions & 26 deletions R/tm_layers_symbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,6 @@
#' `shape` the symbol shape, `lwd` (line width), `lty` (line type), `fill_alpha`
#' (fill color alpha transparency) and `col_alpha` (border color alpha transparency).
#'
#' The visual variable arguments (e.g. `col`) can be specified with either a data
#' variable name (e.g., a spatial vector attribute or a raster layer of the object
#' specified in [tm_shape()]), or with a visual value (for `col`, a color is expected).
#' Multiple values can be specified: in that case facets are created.
#' These facets can be combined with other faceting data variables, specified with [tm_facets()].
#'
#' * The `*.scale` arguments determine the used scale to map the data values to
#' visual variable values. These can be specified with one of the available
#' `tm_scale_*()` functions. The default is specified by the tmap option ([tm_options()]) `scales.var`.
#'
#' * The `*.legend` arguments determine the used legend, specified with [tm_legend()].
#' The default legend and its settings are determined by the tmap options ([tm_options()]) `legend.` .
#'
#' * The `*.chart` arguments specify additional charts, specified with `tm_chart_`, e.g. [tm_chart_histogram()]
#'
#' * The `*.free` arguments determine whether scales are applied freely across facets, or shared.
#' A logical value is required. They can also be specified with a vector of three
#' logical values; these determine whether scales are applied freely per facet dimension.
#' This is only useful when facets are applied (see [tm_facets()]).
#' There are maximally three facet dimensions: rows, columns, and pages. This only
#' applies for a facet grid ([tm_facets_grid()]). For instance, `col.free = c(TRUE, FALSE, FALSE)`
#' means that for the visual variable `col`, each row of facets will have its own
#' scale, and therefore its own legend. For facet wraps and stacks
#' ([tm_facets_wrap()] and [tm_facets_stack()]) there is only one facet dimension,
#' so the `*.free` argument requires only one logical value.
#'
#' A symbol shape specification is one of the following three options.
#' \enumerate{
#' \item{A numeric value that specifies the plotting character of the symbol. See parameter \code{pch} of \code{\link[graphics:points]{points}} and the last example to create a plot with all options. Note that this is not supported for the \code{"view" mode.}}
Expand All @@ -52,7 +26,9 @@
#' @param plot.order Specification in which order the spatial features are drawn.
#' See [tm_plot_order()] for details.
#' @param options options passed on to the corresponding `opt_<layer_function>` function
#' @inherit tm_polygons details
#' @inheritParams tm_polygons
#' @seealso \href{Bubble map example}{https://r-tmap.github.io/tmap/articles/examples_bubble} and \href{terrain map example}{https://r-tmap.github.io/tmap/articles/examples_terrain}
#' @param ... to catch deprecated arguments from version < 4.0
#' @example ./examples/tm_symbols.R
#' @export
Expand Down
Loading

0 comments on commit b0a35d8

Please sign in to comment.