Skip to content

Commit ccf5ebc

Browse files
committed
Update plot_raster function, fix imports and documentation
1 parent 2c97097 commit ccf5ebc

File tree

11 files changed

+67
-9
lines changed

11 files changed

+67
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ rsconnect/
3232
inputs/
3333
J4RTmpFile
3434
.secret
35+
.Rprofile

.gitmodules

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[submodule "modules/Biomass_borealDataPrep"]
2+
path = modules/Biomass_borealDataPrep
3+
url = https://github.com/PredictiveEcology/Biomass_borealDataPrep
4+
[submodule "modules/Biomass_core"]
5+
path = modules/Biomass_core
6+
url = https://github.com/PredictiveEcology/Biomass_core
7+
[submodule "modules/LandR_reforestation"]
8+
path = modules/LandR_reforestation
9+
url = https://github.com/ianmseddy/LandR_reforestation
10+
[submodule "modules/scfm"]
11+
path = modules/scfm
12+
url = https://github.com/PredictiveEcology/scfm
13+
[submodule "modules/Biomass_regeneration"]
14+
path = modules/Biomass_regeneration
15+
url = https://github.com/PredictiveEcology/Biomass_regeneration
16+
[submodule "modules/simpleHarvest"]
17+
path = modules/simpleHarvest
18+
url = https://github.com/pkalanta/simpleHarvest

R/LandR-package.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"_PACKAGE"
1919

2020
## usethis namespace: start
21+
#'
2122
#' @importFrom crayon blue cyan green magenta red
2223
#' @importFrom data.table as.data.table copy data.table dcast fifelse fread
2324
#' @importFrom data.table is.data.table last melt rbindlist
@@ -26,12 +27,17 @@
2627
#' @importFrom fpCompare %==% %>>% %<<% %<=%
2728
#' @importFrom ggplot2 aes coord_equal coord_sf element_blank element_text facet_wrap
2829
#' @importFrom ggplot2 geom_bar geom_hline geom_line geom_point labs geom_raster geom_ribbon geom_sf
30+
#' @importFrom ggplot2 ggplot
2931
#' @importFrom ggplot2 ggplot ggtitle guide_legend guides labs
32+
#' @importFrom ggplot2 ggplot ggtitle theme_bw labs
33+
#' @importFrom ggplot2 ggtitle
34+
#' @importFrom ggplot2 labs
3035
#' @importFrom ggplot2 scale_color_distiller
3136
#' @importFrom ggplot2 scale_fill_distiller scale_fill_manual
3237
#' @importFrom ggplot2 scale_fill_viridis_c scale_fill_viridis_d
3338
#' @importFrom ggplot2 scale_linetype_manual scale_x_discrete
3439
#' @importFrom ggplot2 stat stat_summary sym theme theme_classic unit
40+
#' @importFrom ggplot2 theme_bw
3541
#' @importFrom ggpubr theme_pubr
3642
#' @importFrom ggspatial annotation_north_arrow layer_spatial north_arrow_minimal
3743
#' @importFrom grDevices colorRampPalette dev.off png
@@ -68,5 +74,6 @@
6874
#' @importFrom tools file_ext file_path_sans_ext
6975
#' @importFrom utils capture.output combn count.fields data getFromNamespace head install.packages
7076
#' @importFrom utils str tail untar
77+
#' @importFrom viridis scale_fill_viridis
7178
## usethis namespace: end
7279
NULL

R/plotting.R

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,30 +286,35 @@ plotFunction <- function(ras, studyArea, limits = NULL) {
286286
)
287287
}
288288

289-
#' Plot function for generic SpatRaster objects with Plots
289+
#' Plot function for generic raster objects with Plots
290290
#'
291291
#' @param x SpatRaster for current or cumulative harvest
292292
#' @param title character, the plot title
293293
#' @param subtitle character, the plot subtitle
294294
#'
295295
#' @returns ggplot object
296296
#' @export
297-
#' @importFrom ggplot2 ggplot ggtitle theme_bw labs
298-
#' @importFrom tidyterra geom_spatraster
299-
#' @importFrom viridis scale_fill_viridis
300-
plot_genericMap <- function(x, title = NULL, subtitle = NULL) {
297+
298+
plot_raster <- function(x, title = NULL, subtitle = NULL) {
301299
if (!inherits(x, "SpatRaster")) {
302300
stop("x must be a SpatRaster object.")
303301
}
304302

305-
gg_gm <- ggplot() +
303+
gg_raster <- ggplot() +
306304
geom_spatraster(data = x) +
307305
scale_fill_viridis(na.value = "transparent") +
308306
theme_bw()
309307

310-
if (!is.null(title) || !is.null(subtitle)) {
311-
gg_gm <- gg_gm + ggtitle(title) + labs(subtitle = subtitle)
308+
# if (!is.null(title) || !is.null(subtitle)) {
309+
# gg_raster <- gg_raster + ggtitle(title) + labs(subtitle = subtitle)
310+
if (!is.null(title)) {
311+
gg_raster <- gg_raster + ggtitle(title)
312+
}
313+
if (!is.null(subtitle)) {
314+
gg_raster <- gg_raster + labs(subtitle = subtitle)
312315
}
313316

314-
gg_gm # return ggplot object
317+
gg_raster # return ggplot object
315318
}
319+
320+

man/plot_raster.Rd

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

modules/Biomass_borealDataPrep

Submodule Biomass_borealDataPrep added at 8c64cce

modules/Biomass_core

Submodule Biomass_core added at e619089

modules/Biomass_regeneration

Submodule Biomass_regeneration added at a991e33

modules/LandR_reforestation

Submodule LandR_reforestation added at 72f02b3

modules/scfm

Submodule scfm added at 15aca67

0 commit comments

Comments
 (0)