diff --git a/.gitignore b/.gitignore index ce50907..30674f2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ inst/doc doc Meta docs/ - +*.pdf diff --git a/DESCRIPTION b/DESCRIPTION index 1f786a4..f97a950 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,7 @@ URL: https://reginalexavier.github.io/OpenLand/, https://github.com/reginalexavi BugReports: https://github.com/reginalexavier/OpenLand/issues Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.3.1 Depends: R (>= 3.4.0) Imports: diff --git a/R/OpenLand-package.R b/R/OpenLand-package.R index 65b2fc8..4d316e7 100644 --- a/R/OpenLand-package.R +++ b/R/OpenLand-package.R @@ -1,3 +1,4 @@ +"_PACKAGE" #' OpenLand: land use and cover (LUC) time series analysis in R. #' #' @@ -15,7 +16,7 @@ #' \code{\link{contingencyTable}}, #' #' @author Reginal Exavier \email{reginalexavier@@rocketmail.com}, Peter Zeilhofer \email{zeilhoferpeter@@gmail.com} -#' @docType package +# @docType package #' @name OpenLand-package #' @aliases OpenLand #' diff --git a/R/demolandscape.R b/R/demolandscape.R index 4965612..5cfea7b 100644 --- a/R/demolandscape.R +++ b/R/demolandscape.R @@ -1,6 +1,6 @@ #' Create Raster with Random pixel Value #' -#' This function create a raster serie with some setup like the layer name and +#' This function creates a raster series with some setup like the layer name and #' the sample value for the lulc #' #' @param year numeric. A vector of year, first and last included. @@ -13,7 +13,7 @@ #' @param ymx numeric. y maximum extent. #' @param crs character. the coordinate referencing system. #' @param category A numeric vector of the raster categories. -#' @param prob A numreric vector of the probability of occurrence for the +#' @param prob A numeric vector of the probability of occurrence for the #' category list. #' #' diff --git a/R/generalfunctions.R b/R/generalfunctions.R index b9e3bb6..51bb69b 100644 --- a/R/generalfunctions.R +++ b/R/generalfunctions.R @@ -1,7 +1,7 @@ #' Summary of multiple parameters in a raster directory #' -#' Listing major charateristics of raster inputs. Those characteristics are the +#' Listing major characteristics of raster inputs. Those characteristics are the #' dimensions, the resolution, the extent, the values (min, max) and the #' coordinate reference system. #' @@ -24,10 +24,10 @@ #' summary_dir <- function(path) { - if ((class(path) == "list") & - (c(class(path[[1]])) == "RasterLayer")) { + if (inherits(path, "list") & + inherits(path[[1]], "RasterLayer")) { layer_list <- path - } else if (class(path) == "character") { + } else if (inherits(path, "character")) { raster_files <- list.files(path, @@ -87,8 +87,8 @@ summary_dir <- function(path) { #' summary_map <- function(path) { rastermap <- - if (class(path) != "character") { - if (class(path) == "RasterLayer") { + if (!inherits(path, "character")) { + if (inherits(path, "RasterLayer")) { path } else { path[[1]] diff --git a/R/otherplots.R b/R/otherplots.R index 94d497a..52f89aa 100644 --- a/R/otherplots.R +++ b/R/otherplots.R @@ -410,7 +410,7 @@ netgrossplot <- )) + scale_fill_manual(values = color) + labs(fill = legend_title) + - geom_hline(yintercept = 0, size = .3) + + geom_hline(yintercept = 0, linewidth = .3) + xlab(xlab) + ylab(ylab) + ggtitle(title) + diff --git a/R/plotMethods.R b/R/plotMethods.R index a59e59b..5743fbd 100644 --- a/R/plotMethods.R +++ b/R/plotMethods.R @@ -79,8 +79,8 @@ methods::setMethod( ) + geom_hline(aes(yintercept = dataset[[4]], color = "U"), linetype = 5, - size = .5) + - geom_hline(aes(yintercept = 0), size = .01) + + linewidth = .5) + + geom_hline(aes(yintercept = 0), linewidth = .01) + scale_fill_manual(values = c(color_bar[[1]], color_bar[[2]])) + ylab(NULL) + scale_color_manual(values = "black") + @@ -97,7 +97,7 @@ methods::setMethod( xend = (length(unique(dataset[[1]])) / 2) + leg_curv[[2]], yend = dataset[[4]] + leg_curv[[1]] ), - size = .6, + linewidth = .6, curvature = .1, arrow = arrow(length = unit(2, "mm"), ends = "first") ) + @@ -140,7 +140,7 @@ methods::setMethod( coord_flip() + xlab(expression(paste("Periodo de tempo [ ", Y[t], ",", Y[t + 1], "]"))) + ylab(NULL) + - geom_hline(aes(yintercept = 0), size = .01) + + geom_hline(aes(yintercept = 0), linewidth = .01) + scale_y_reverse(expand = expansion(mult = c(0.01, 0))) + scale_x_discrete(position = "top", expand = expansion(mult = c(0.06, 0.06))) + theme( @@ -231,10 +231,10 @@ methods::setMethod( levels(dataset[[2]])))]])) + xlab(NULL) + ylab(NULL) + - geom_hline(aes(yintercept = 0), size = .3) + + geom_hline(aes(yintercept = 0), linewidth = .3) + geom_hline(aes(yintercept = dataset[[6]], color = names(dataset)[[6]]), linetype = 5, - size = .3) + + linewidth = .3) + scale_color_manual(values = "black") + coord_flip() + labs(fill = labs[[1]], colour = labs[[2]]) + @@ -290,7 +290,7 @@ methods::setMethod( levels(dataset[[2]])))]])) + xlab(NULL) + ylab(NULL) + - geom_hline(aes(yintercept = 0), size = .3) + + geom_hline(aes(yintercept = 0), linewidth = .3) + coord_flip() + labs(fill = "Categories") + scale_y_reverse(expand = expansion(mult = c(0.01, 0))) + @@ -390,10 +390,10 @@ methods::setMethod( levels(dataset[[2]])))]])) + xlab(NULL) + ylab(NULL) + - geom_hline(aes(yintercept = 0), size = .3) + + geom_hline(aes(yintercept = 0), linewidth = .3) + geom_hline(aes(yintercept = dataset[[7]], color = names(dataset)[[7]]), linetype = 5, - size = .3) + + linewidth = .3) + scale_color_manual(values = "black") + coord_flip() + labs(fill = labs[[1]], colour = labs[[2]]) + @@ -448,7 +448,7 @@ methods::setMethod( levels(dataset[[2]])))]])) + xlab(NULL) + ylab(NULL) + - geom_hline(aes(yintercept = 0), size = .3) + + geom_hline(aes(yintercept = 0), linewidth = .3) + coord_flip() + labs(fill = "Categories") + scale_y_reverse(expand = expansion(mult = c(0.01, 0))) + diff --git a/man/OpenLand-package.Rd b/man/OpenLand-package.Rd index 2c0d244..b49193a 100644 --- a/man/OpenLand-package.Rd +++ b/man/OpenLand-package.Rd @@ -1,6 +1,5 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/OpenLand-package.R -\docType{package} \name{OpenLand-package} \alias{OpenLand-package} \alias{OpenLand} diff --git a/man/dot-demo_landscape.Rd b/man/dot-demo_landscape.Rd index ca6d847..ad53ea5 100644 --- a/man/dot-demo_landscape.Rd +++ b/man/dot-demo_landscape.Rd @@ -39,14 +39,14 @@ \item{category}{A numeric vector of the raster categories.} -\item{prob}{A numreric vector of the probability of occurrence for the +\item{prob}{A numeric vector of the probability of occurrence for the category list.} } \value{ list } \description{ -This function create a raster serie with some setup like the layer name and +This function creates a raster series with some setup like the layer name and the sample value for the lulc } \examples{ diff --git a/man/summary_dir.Rd b/man/summary_dir.Rd index 0f7c941..69cd53d 100644 --- a/man/summary_dir.Rd +++ b/man/summary_dir.Rd @@ -14,7 +14,7 @@ analysed.} Table with the raster parameters in columns } \description{ -Listing major charateristics of raster inputs. Those characteristics are the +Listing major characteristics of raster inputs. Those characteristics are the dimensions, the resolution, the extent, the values (min, max) and the coordinate reference system. } diff --git a/tests/testthat/test_generalfunctions.R b/tests/testthat/test_generalfunctions.R index 45eb649..d49e4d9 100644 --- a/tests/testthat/test_generalfunctions.R +++ b/tests/testthat/test_generalfunctions.R @@ -24,19 +24,25 @@ test_that("Behavior of acc_changes", { }) -# testFolder <- tempdir() -# -# lapply(.demo_landscape(year = 2000:2004), function(x) -# raster::writeRaster(x, -# filename = file.path(testFolder, paste0(names(x), ".tif")), -# datatype = 'INT1U', -# overwrite = TRUE -# )) +if (FALSE){ + testFolder <- tempdir() + + lapply(.demo_landscape(year = 2000:2004), function(x) + raster::writeRaster(x, + filename = file.path(testFolder, paste0(names(x), ".tif")), + datatype = 'INT1U', + overwrite = TRUE + )) + + expect_silent(summary_dir(testFolder)) + expect_equal(nrow(summary_dir(testFolder)), 5) + +} + test_that("Behavior of summary_dir", { - # expect_silent(summary_dir(testFolder)) - # expect_equal(nrow(summary_dir(testFolder)), 5) + expect_silent(summary_dir(demo_raster)) expect_visible(summary_dir(demo_raster)) expect_error(summary_dir(raster::stack(demo_raster))) diff --git a/tests/testthat/test_plots.R b/tests/testthat/test_plots.R index 757e265..ec0c28c 100644 --- a/tests/testthat/test_plots.R +++ b/tests/testthat/test_plots.R @@ -53,11 +53,14 @@ test_that("Behavior of the other plots", { expect_visible(sankeyLand(demo_cont$lulc_Multistep, demo_cont$tb_legend)) + expect_output(str(barplotLand(demo_cont$lulc_Multistep, demo_cont$tb_legend)), "List of 11") + expect_output(str(netgrossplot(demo_cont$lulc_Multistep, demo_cont$tb_legend)), "List of 11") expect_s3_class(barplotLand(demo_cont$lulc_Multistep, demo_cont$tb_legend), "ggplot") - #expect_null(str(chordDiagramLand(demo_cont$lulc_Onestep, demo_cont$tb_legend))) + # expect_type(str(chordDiagramLand(demo_cont$lulc_Onestep, demo_cont$tb_legend)), "NULL") expect_s3_class(netgrossplot(demo_cont$lulc_Multistep, demo_cont$tb_legend), "ggplot") expect_output(str(sankeyLand(demo_cont$lulc_Onestep, demo_cont$tb_legend)), "List of 8") expect_output(str(sankeyLand(demo_cont$lulc_Multistep, demo_cont$tb_legend)), "List of 8") }) + diff --git a/vignettes/openland_vignette.Rmd b/vignettes/openland_vignette.Rmd index 56322ba..e2c7de2 100644 --- a/vignettes/openland_vignette.Rmd +++ b/vignettes/openland_vignette.Rmd @@ -3,7 +3,7 @@ title: "Quick introduction to the OpenLand package" output: rmarkdown::html_vignette bibliography: papers_OpenLand.bib vignette: > - %\VignetteIndexEntry{Quick Intro for OpenLand Package} + %\VignetteIndexEntry{Quick introduction to the OpenLand package} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -90,7 +90,7 @@ For our study area, `contingenceTable(input_raster = SaoLourencoBasin, pixelreso ```{r} -# SL_2002_2014 <- contingenceTable(input_raster = SaoLourencoBasin, pixelresolution = 30) +# SL_2002_2014 <- contingencyTable(input_raster = SaoLourencoBasin, pixelresolution = 30) SL_2002_2014