Skip to content

Commit 7aed9af

Browse files
fixes
1 parent 3ad03f0 commit 7aed9af

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Imports:
1515
ragg
1616
Depends:
1717
R (>= 3.2.2)
18-
RoxygenNote: 7.1.1
18+
RoxygenNote: 7.1.2
1919
Suggests:
2020
knitr,
2121
maps,

R/rasterise.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ NULL
77
#' @param dpi integer Sets the desired resolution in dots per inch (default=NULL).
88
#' @param dev string Specifies the device used, which can be one of: \code{"cairo"}, \code{"ragg"} or \code{"ragg_png"} (default="cairo").
99
#' @param scale numeric Scaling factor to modify the raster object size (default=1). The parameter 'scale=1' results in an object size that is unchanged, 'scale'>1 increase the size, and 'scale'<1 decreases the size. These parameters are passed to 'height' and 'width' of grid::grid.raster(). Please refer to 'rasterise()' and 'grid::grid.raster()' for more details.
10+
#' @param ... other arguments
1011
#' @details The default \code{dpi} (\code{NULL} (i.e. let the device decide)) can conveniently be controlled by setting the option \code{"ggrastr.default.dpi"} (e.g. \code{options("ggrastr.default.dpi" = 30)} for drafting).
1112
#' @return A modified \code{Layer} object.
1213
#' @examples
@@ -32,21 +33,21 @@ NULL
3233
rasterise <- function(input, ...) UseMethod("rasterise", input)
3334

3435
#' @rdname rasterise
35-
#' @param layer A \code{Layer} object, typically constructed with a call to a
36+
#' @param input A \code{Layer} object, typically constructed with a call to a
3637
#' \code{geom_*()} or \code{stat_*()} function.
3738
#' @author Teun van den Brand <t.vd.brand@nki.nl>
3839
#' @export
39-
rasterise.Layer <- function(layer, dpi=NULL, dev="cairo", scale=1) {
40+
rasterise.Layer <- function(input, dpi=NULL, dev="cairo", scale=1, ...) {
4041
dev <- match.arg(dev, c("cairo", "ragg", "ragg_png"))
4142
if (is.null(dpi)) {
4243
dpi <- getOption("ggrastr.default.dpi")
4344
}
4445

4546
# Take geom from input layer
46-
old.geom <- layer$geom
47+
old.geom <- input$geom
4748
# Reconstruct input layer
4849
ggproto(
49-
NULL, layer,
50+
NULL, input,
5051
# Let the new geom inherit from the old geom
5152
geom = ggproto(
5253
NULL, old.geom,
@@ -66,7 +67,7 @@ rasterise.Layer <- function(layer, dpi=NULL, dev="cairo", scale=1) {
6667
#' @param input input list with rasterizable ggplot objects
6768
#' @rdname rasterise
6869
#' @export
69-
rasterise.list <- function(input, dpi=NULL, dev="cairo", scale=1) {
70+
rasterise.list <- function(input, dpi=NULL, dev="cairo", scale=1, ...) {
7071
# geom_sf returns a list and requires extra logic here to handle gracefully
7172
# Check if list contains layers
7273
has.layer <- rapply(input, is.layer, how = "list")
@@ -80,23 +81,24 @@ rasterise.list <- function(input, dpi=NULL, dev="cairo", scale=1) {
8081
return(input)
8182
}
8283

83-
#' @param gg ggplot plot object to rasterize
84+
#' @param input ggplot plot object to rasterize
8485
#' @param layers list of layer types that should be rasterized
8586
#' @rdname rasterise
8687
#' @export
87-
rasterise.ggplot <- function(gg, layers=c('Point', 'Tile'), dpi=NULL, dev="cairo", scale=1) {
88-
gg$layers <- lapply(gg$layers, function(lay) {
88+
rasterise.ggplot <- function(input, layers=c('Point', 'Tile'), dpi=NULL, dev="cairo", scale=1, ...) {
89+
input$layers <- lapply(input$layers, function(lay) {
8990
if (inherits(lay$geom, paste0('Geom', layers))) {
9091
rasterise(lay, dpi=dpi, dev=dev, scale=scale)
9192
} else{
9293
lay
9394
}
9495
})
95-
return(gg)
96+
return(input)
9697
}
9798

9899

99-
#' @export rasterize
100+
#' @rdname rasterise
101+
#' @export
100102
rasterize <- rasterise
101103

102104
#' @export

man/rasterise.Rd

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)