diff --git a/DESCRIPTION b/DESCRIPTION index 4a63b792..c4be5f51 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -73,4 +73,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index 7b781c16..45e28cfe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,6 +78,7 @@ S3method(tmapLeafletLegPlot,tm_title) S3method(tmapReproject,dimensions) S3method(tmapReproject,sfc) S3method(tmapReproject,stars) +S3method(tmapShape,Raster) S3method(tmapShape,SpatRaster) S3method(tmapShape,sf) S3method(tmapShape,stars) @@ -223,6 +224,7 @@ importFrom(grDevices,dev.size) importFrom(grDevices,png) importFrom(grDevices,rgb) importFrom(htmlwidgets,saveWidget) +importFrom(leaflet,providers) importFrom(rlang,expr) importFrom(rlang,missing_arg) importFrom(utils,browseURL) diff --git a/R/tm_layers_text.R b/R/tm_layers_text.R index bc90507d..c7040799 100644 --- a/R/tm_layers_text.R +++ b/R/tm_layers_text.R @@ -53,6 +53,10 @@ #' groups 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 bgcol,bgcol.scale,bgcol.legend,bgcol.free Visual variable that determines +#' the background color. See Details. +#' @param bgcol_alpha,bgcol_alpha.scale,bgcol_alpha.legend,bgcol_alpha.free Visual variable that determines +#' the background color transparency. See Details. #' @param ... to catch deprecated arguments from version < 4.0 #' @example ./examples/tm_text.R #' @export diff --git a/R/tmapLeafletLegend.R b/R/tmapLeafletLegend.R index 00ea733d..8a1c7298 100644 --- a/R/tmapLeafletLegend.R +++ b/R/tmapLeafletLegend.R @@ -219,11 +219,12 @@ tmapLeaflet_legend = function(cmp, lf, o, orientation) { } - +#' @exportS3Method NULL tmapLeafletLegPlot.tm_legend_standard_portrait = function(cmp, lf, o) { tmapLeaflet_legend(cmp, lf, o, orientation = "vertical") } +#' @exportS3Method NULL tmapLeafletLegPlot.tm_legend_standard_landscape = function(cmp, lf, o) { tmapLeaflet_legend(cmp, lf, o, orientation = "horizontal") } diff --git a/R/tmapShape.R b/R/tmapShape.R index b3fae02b..32533da9 100644 --- a/R/tmapShape.R +++ b/R/tmapShape.R @@ -83,7 +83,7 @@ tmapShape = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, } - +#' @export tmapShape.Raster = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) { tmapShape.SpatRaster(terra::rast(shp), is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) } diff --git a/man/Shapes.Rd b/man/Shapes.Rd index aba21353..dd59d99f 100644 --- a/man/Shapes.Rd +++ b/man/Shapes.Rd @@ -22,7 +22,7 @@ NLD_muni } \description{ Maps of the world and the Netherlands (province and municipality level), -class \code{\link[sf:sf]{sf}} +class \code{\link[sf:sf-package]{sf}} } \details{ The default projections for these maps are Eckhart IV (World) and diff --git a/man/qtm.Rd b/man/qtm.Rd index 3476bbe4..0d1db7c7 100644 --- a/man/qtm.Rd +++ b/man/qtm.Rd @@ -32,7 +32,7 @@ qtm( \arguments{ \item{shp}{One of: \itemize{ -\item shape object, which is an object from a class defined by the \code{\link[sf:sf]{sf}} +\item shape object, which is an object from a class defined by the \code{\link[sf:sf-package]{sf}} or \code{\link[stars:st_as_stars]{stars}} package. Objects from the packages \code{sp} and \code{raster} are also supported, but discouraged. \item Not specified, i.e. \code{qtm()} is executed. In this case a plain interactive diff --git a/man/tm_basemap.Rd b/man/tm_basemap.Rd index 62209bd4..d9eacc92 100644 --- a/man/tm_basemap.Rd +++ b/man/tm_basemap.Rd @@ -67,5 +67,12 @@ if (requireNamespace("maptiles")) { tm_basemap("OpenTopoMap") + tm_shape(World) + tm_polygons(fill = NA, col = "black") + + tm_basemap("CartoDB.PositronNoLabels") + + tm_shape(NLD_prov, crs = 4236) + + tm_borders() + + tm_facets_wrap("name") + + tm_tiles("CartoDB.PositronOnlyLabels") + } } diff --git a/man/tm_facets.Rd b/man/tm_facets.Rd index e466fc3c..ae60975e 100644 --- a/man/tm_facets.Rd +++ b/man/tm_facets.Rd @@ -31,7 +31,8 @@ tm_facets( textNA = "Mssing", scale.factor = 2, type = NA, - along = NULL + along = NULL, + free.scales = NULL ) tm_facets_grid(rows = NULL, columns = NULL, pages = NULL, ...) @@ -111,6 +112,8 @@ By default, \code{scale.factor=2}.} \item{along}{deprecated Please use \code{tm_facets_page()}} +\item{free.scales}{deprecated. Please use the \code{.free} arguments in the layer functions, e.g. \code{fill.free} in \code{tm_polygons}.} + \item{...}{passed on to \code{tm_facets()}} } \description{ diff --git a/man/tm_shape.Rd b/man/tm_shape.Rd index b097f015..0b00ef90 100644 --- a/man/tm_shape.Rd +++ b/man/tm_shape.Rd @@ -35,5 +35,5 @@ bounding box of the map?} } \description{ Specify a shape, which is a spatial object from one of these spatial object -class packages: \code{\link[sf:sf]{sf}}, \code{\link[stars:st_as_stars]{stars}}, or \code{terra}. +class packages: \code{\link[sf:sf-package]{sf}}, \code{\link[stars:st_as_stars]{stars}}, or \code{terra}. } diff --git a/man/tm_text.Rd b/man/tm_text.Rd index 8f5143f4..89506a4a 100644 --- a/man/tm_text.Rd +++ b/man/tm_text.Rd @@ -26,6 +26,14 @@ tm_text( fontface.legend = tm_legend(), fontface.free = NA, fontfamily = "", + bgcol = tm_const(), + bgcol.scale = tm_scale(), + bgcol.legend = tm_legend(), + bgcol.free = NA, + bgcol_alpha = tm_const(), + bgcol_alpha.scale = tm_scale(), + bgcol_alpha.legend = tm_legend(), + bgcol_alpha.free = NA, shadow = FALSE, plot.order = tm_plot_order("AREA", reverse = FALSE, na.order = "bottom"), trans.args = list(points.only = "ifany"), @@ -54,6 +62,12 @@ the font face. See Details.} \item{fontfamily}{The font family. See \link[grid:gpar]{gpar()} for details.} +\item{bgcol, bgcol.scale, bgcol.legend, bgcol.free}{Visual variable that determines +the background color. See Details.} + +\item{bgcol_alpha, bgcol_alpha.scale, bgcol_alpha.legend, bgcol_alpha.free}{Visual variable that determines +the background color transparency. See Details.} + \item{shadow}{Shadow behind the text. Logical or color.} \item{plot.order}{Specification in which order the spatial features are drawn. @@ -107,37 +121,16 @@ own legend. For facet wraps and stacks (\code{\link[=tm_facets_wrap]{tm_facets_w there is only one facet dimension, so the \code{.free} argument requires only one logical value. } \examples{ -data(rivers) - -tm_shape(rivers) + - tm_lines() - -tm_shape(rivers) + - tm_lines(lwd = "scalerank") - -tm_shape(rivers) + - tm_lines(lwd = "scalerank", - lwd.scale = tm_scale_continuous(values.scale = 2, n = 20), - lwd.legend = tm_legend(orientation = "landscape", item.width = 2), - col = "type", - col.scale = tm_scale(values = c("darkblue", "darkred"))) - -tm_shape(rivers) + - tm_lines(lwd = "scalerank", - lty = "scalerank", - col = "scalerank", - col.scale = tm_scale_categorical(), - lty.legend = tm_legend_combine("lwd"), - col.legend = tm_legend_combine("lwd")) - - -### tmap3 - tm_shape(World) + - tm_fill() + - tm_shape(rivers) + - tm_lines(col="black", lwd="scalerank", scale=2, legend.lwd.show = FALSE) + - tm_style("cobalt", title = "Rivers of the World") + - tm_format("World") + tm_text(text = "name", + size = .4, + bgcol = "economy") +tm_shape(World) + + tm_text(text = "name", + size = .4, + bgcol = "economy", + bgcol.scale = tm_scale_categorical(values = cols4all::.P$hcl$cat$set2), + bgcol_alpha = "pop_est", + bgcol_alpha.scale = tm_scale_intervals(style = "kmeans")) } diff --git a/man/tmap-package.Rd b/man/tmap-package.Rd index 6e3f28f0..ce419f5f 100644 --- a/man/tmap-package.Rd +++ b/man/tmap-package.Rd @@ -107,11 +107,11 @@ Create icons: \section{Spatial datasets}{ \tabular{ll}{ -\code{\link{World}}\tab World country data (\code{\link[sf:sf]{sf}} object of polygons) \cr -\code{\link{NLD_prov}}\tab Netherlands province data (\code{\link[sf:sf]{sf}} object of polygons) \cr -\code{\link{NLD_muni}}\tab Netherlands municipal data (\code{\link[sf:sf]{sf}} object of polygons) \cr -\code{\link{metro}}\tab Metropolitan areas (\code{\link[sf:sf]{sf}} object of points) \cr -\code{\link{rivers}}\tab Rivers (\code{\link[sf:sf]{sf}} object of lines) \cr +\code{\link{World}}\tab World country data (\code{\link[sf:sf-package]{sf}} object of polygons) \cr +\code{\link{NLD_prov}}\tab Netherlands province data (\code{\link[sf:sf-package]{sf}} object of polygons) \cr +\code{\link{NLD_muni}}\tab Netherlands municipal data (\code{\link[sf:sf-package]{sf}} object of polygons) \cr +\code{\link{metro}}\tab Metropolitan areas (\code{\link[sf:sf-package]{sf}} object of points) \cr +\code{\link{rivers}}\tab Rivers (\code{\link[sf:sf-package]{sf}} object of lines) \cr \code{\link{land}}\tab Global land cover (\code{\link[stars:st_as_stars]{stars}} object)\cr } } diff --git a/man/tmap_options.Rd b/man/tmap_options.Rd index 2240c0f8..29782728 100644 --- a/man/tmap_options.Rd +++ b/man/tmap_options.Rd @@ -40,6 +40,7 @@ tmap options \code{crs} \tab Map crs (see \code{\link[=tm_shape]{tm_shape()}}). \code{NA} means the crs is specified in \code{\link[=tm_shape]{tm_shape()}}. The crs that is used by the transformation functions is defined in \code{\link[=tm_shape]{tm_shape()}}. \cr \code{facet.max} \tab Maximum number of facets \cr \code{facet.flip} \tab Should facets be flipped (in case of facet wrap)? This can also be set via \code{\link[=tm_facets_flip]{tm_facets_flip()}} \cr + \code{free.scales} \tab For backward compatibility: if this value is set, it will be used to impute the free arguments in the layer functions \cr \code{raster.max.cells} \tab Maximum number of raster grid cells \cr \code{show.messages} \tab Show messages? \cr \code{show.warnings} \tab Show warnings? \cr