Skip to content

Commit

Permalink
Use new plotting fns from rasterVis & lattice, fixes #169 fixes #170
Browse files Browse the repository at this point in the history
  • Loading branch information
courtiol committed Oct 15, 2023
1 parent 16a52fc commit 7eff0e8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 160 deletions.
4 changes: 2 additions & 2 deletions IsoriX/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Imports:
graphics,
grDevices,
grid,
lattice,
lattice (>= 0.22-2),
latticeExtra,
methods,
numDeriv,
rasterVis (>= 0.30),
rasterVis (>= 0.51.6),
spaMM (>= 3.13),
stats,
terra,
Expand Down
99 changes: 0 additions & 99 deletions IsoriX/R/interim_avoid_sp.R

This file was deleted.

94 changes: 35 additions & 59 deletions IsoriX/R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,13 @@ plot.SpatRaster <- function(x, ...) {
if (!sources$draw) {
sources_layer <- latticeExtra::layer()
} else {
sources_layer <- latticeExtra::layer(lpoints.SpatVector(sources,
col = pt$col,
cex = pt$cex,
pch = pt$pch,
lwd = pt$lwd
),
data = list(sources = x$sp_points$sources,
pt = sources,
lpoints.SpatVector = lpoints.SpatVector ## TODO: figure out how to pass generic instead of method
)
)
sources_layer <- latticeExtra::layer(lattice::lpoints(sources,
col = pt$col,
cex = pt$cex,
pch = pt$pch,
lwd = pt$lwd),
data = list(sources = x$sp_points$sources,
pt = sources))
}

## layer for calibration points
Expand All @@ -886,17 +882,13 @@ plot.SpatRaster <- function(x, ...) {
if (!calibs$draw) {
calibs_layer <- latticeExtra::layer()
} else {
calibs_layer <- latticeExtra::layer(lpoints.SpatVector(calibs,
col = pt$col,
cex = pt$cex,
pch = pt$pch,
lwd = pt$lwd
),
data = list(calibs = x$sp_points$calibs,
pt = calibs,
lpoints.SpatVector = lpoints.SpatVector ## TODO: figure out how to pass generic instead of method
)
)
calibs_layer <- latticeExtra::layer(lattice::lpoints(calibs,
col = pt$col,
cex = pt$cex,
pch = pt$pch,
lwd = pt$lwd),
data = list(calibs = x$sp_points$calibs,
pt = calibs))
}
}

Expand All @@ -907,61 +899,45 @@ plot.SpatRaster <- function(x, ...) {
if (!assigns$draw) {
assigns_layer <- latticeExtra::layer()
} else {
assigns_layer <- latticeExtra::layer(lpoints.SpatVector(assigns,
col = pt$col,
cex = pt$cex,
pch = pt$pch,
lwd = pt$lwd
),
data = list(assigns = x$sp_points$assigns,
pt = assigns,
lpoints.SpatVector = lpoints.SpatVector ## TODO: figure out how to pass generic instead of method
)
)
assigns_layer <- latticeExtra::layer(lattice::lpoints(assigns,
col = pt$col,
cex = pt$cex,
pch = pt$pch,
lwd = pt$lwd),
data = list(assigns = x$sp_points$assigns,
pt = assigns))
}
}

## layer for country borders
if (is.null(borders$borders)) {
borders_layer <- latticeExtra::layer()
} else {
borders_layer <- latticeExtra::layer(lpolygon.SpatVector(b$borders,
lwd = b$lwd,
border = b$col
),
data = list(b = borders,
lpolygon.SpatVector = lpolygon.SpatVector ## TODO: figure out how to pass generic instead of method
)
)
borders_layer <- latticeExtra::layer(lattice::lpolygon(b$borders,
lwd = b$lwd,
border = b$col),
data = list(b = borders))
}

## layer for mask
if (is.null(mask$mask)) {
mask_layer <- latticeExtra::layer()
} else {
mask_layer <- latticeExtra::layer(lpolygon.SpatVector(m$mask,
col = m$fill,
border = m$col,
lwd = m$lwd
),
data = list(m = mask,
lpolygon.SpatVector = lpolygon.SpatVector ## TODO: figure out how to pass generic instead of method
)
)
mask_layer <- latticeExtra::layer(lattice::lpolygon(m$mask,
col = m$fill,
border = m$col,
lwd = m$lwd),
data = list(m = mask))
}

if (is.null(mask2$mask)) {
mask2_layer <- latticeExtra::layer()
} else {
mask2_layer <- latticeExtra::layer(lpolygon.SpatVector(m$mask,
col = m$fill,
border = m$col,
lwd = m$lwd
),
data = list(m = mask2,
lpolygon.SpatVector = lpolygon.SpatVector ## TODO: figure out how to pass generic instead of method
)
)
mask2_layer <- latticeExtra::layer(lattice::lpolygon(m$mask,
col = m$fill,
border = m$col,
lwd = m$lwd),
data = list(m = mask2))
}

layers <- list(sources_layer = sources_layer,
Expand Down

0 comments on commit 7eff0e8

Please sign in to comment.