Skip to content

Commit

Permalink
done #873
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed May 5, 2024
1 parent 997f04a commit 749128c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 8 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export(opt_tm_lines)
export(opt_tm_markers)
export(opt_tm_polygons)
export(opt_tm_raster)
export(opt_tm_rgb)
export(opt_tm_sf)
export(opt_tm_squares)
export(opt_tm_symbols)
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
5 changes: 3 additions & 2 deletions R/tm_layers_raster.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#' @rdname tm_raster
#' @name opt_tm_raster
#' @param interpolate Should the raster image be interpolated? Currently only applicable in view mode (passed on to [`grid`][grid::rasterGrob()])
#' @export
opt_tm_raster = function() {
opt_tm_raster = function(interpolate = FALSE) {
list(trans.args = list(),
mapping.args = list())
mapping.args = list(interpolate = interpolate))
}


Expand Down
14 changes: 12 additions & 2 deletions R/tm_layers_rgb.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#' @rdname tm_raster
#' @name opt_tm_rgb
#' @export
opt_tm_rgb = function(interpolate = TRUE) {
list(trans.args = list(),
mapping.args = list(interpolate = interpolate))
}

#' Map layer: RGB
#'
#' @param col,col.scale,col.legend,col.chart,col.free Visual variable that determines
#' the col color.
#' @param options options passed on to the corresponding `opt_<layer_function>` function
#' @export
tm_rgb = function(col = tm_mv(1:3),
col.scale = tm_scale_rgb(),
col.legend = tm_legend(),
col.chart = tm_chart_none(),
col.free = NA) {
do.call(tm_raster, args = list(col = col, col.scale = col.scale, col.legend = col.legend, col.chart = col.chart, col.free = col.free))
col.free = NA,
options = opt_tm_rgb()) {
do.call(tm_raster, args = list(col = col, col.scale = col.scale, col.legend = col.legend, col.chart = col.chart, col.free = col.free, options = options))
}
3 changes: 2 additions & 1 deletion R/tmapGridRaster.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tmapGridRaster <- function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page, id, pane, group, o, ...) {
args = list(...)
gts = get("gts", .TMAP_GRID)
#bbx = get("bbx", .TMAP_GRID)

Expand Down Expand Up @@ -70,7 +71,7 @@ tmapGridRaster <- function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page,
}
m[is.na(m)] = NA #"#0000FF"

grb = grid::rasterGrob(m, x=cx, y=cy, width=width, height=height, interpolate = FALSE, name = paste0("raster_", id)) #gpl$raster.misc$interpolate
grb = grid::rasterGrob(m, x=cx, y=cy, width=width, height=height, interpolate = args$interpolate, name = paste0("raster_", id)) #gpl$raster.misc$interpolate
gt = grid::addGrob(gts[[facet_page]], grb, gPath = grid::gPath(paste0("gt_facet_", rc_text)))
gts[[facet_page]] = gt
assign("gts", gts, envir = .TMAP_GRID)
Expand Down
18 changes: 18 additions & 0 deletions man/opt_tm_donuts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions man/tm_raster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/tm_rgb.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 749128c

Please sign in to comment.