R/qgis_rasterlayerstatistics.R

Defines functions qgis_rasterlayerstatistics

Documented in qgis_rasterlayerstatistics

##' QGIS Algorithm provided by QGIS (native c++) Raster layer statistics (native:rasterlayerstatistics). This algorithm computes basic statistics from the values in a given band of the raster layer.
##'
##' @title QGIS algorithm - Raster layer statistics
##'
##' @param INPUT `raster` - Input layer. Path to a raster layer.
##' @param BAND `band` - Band number. Integer value representing an existing raster band number.
##' @param OUTPUT_HTML_FILE `fileDestination` - Statistics. Path for new file.
##' @param ... further parameters passed to `qgisprocess::qgis_run_algorithm()`
##' @param .complete_output logical specifying if complete out of `qgisprocess::qgis_run_algorithm()` should be used (`TRUE`) or first output (most likely the main) should read (`FALSE`). Default value is `TRUE`.
##' @param .quiet logical specifying if parameter `.quiet` for `qgisprocess::qgis_run_algorithm()` Default value is `TRUE`.
##' @param .messages logical specifying if messages from `qgisprocess::qgis_run_algorithm()` should be printed (`TRUE`) or not (`FALSE`). Default value is `FALSE`.
##'
##' @details
##' ## Outputs description
##' * COUNT - outputNumber - Count of non-NoData pixels
##' * MAX - outputNumber - Maximum value
##' * MEAN - outputNumber - Mean value
##' * MIN - outputNumber - Minimum value
##' * OUTPUT_HTML_FILE - outputHtml - Statistics
##' * RANGE - outputNumber - Range
##' * STD_DEV - outputNumber - Standard deviation
##' * SUM - outputNumber - Sum
##' * SUM_OF_SQUARES - outputNumber - Sum of the squares
##'
##'
##' @export
##' @md
##' @importFrom qgisprocess qgis_run_algorithm

qgis_rasterlayerstatistics <- function(INPUT = qgisprocess:::qgis_default_value(), BAND = qgisprocess:::qgis_default_value(), OUTPUT_HTML_FILE = qgisprocess:::qgis_default_value(),..., .complete_output = .complete_output_option(), .quiet = .quiet_option(), .messages = .message_option()) {

  check_algorithm_necessities("native:rasterlayerstatistics")

  if (.messages){
    output <- qgisprocess::qgis_run_algorithm("native:rasterlayerstatistics", `INPUT` = INPUT, `BAND` = BAND, `OUTPUT_HTML_FILE` = OUTPUT_HTML_FILE,..., .quiet = .quiet)
  } else {
    suppressMessages(
      output <- qgisprocess::qgis_run_algorithm("native:rasterlayerstatistics", `INPUT` = INPUT, `BAND` = BAND, `OUTPUT_HTML_FILE` = OUTPUT_HTML_FILE,..., .quiet = .quiet)
      )
  }

  if (.complete_output) {
    return(output)
  }
  else{
    qgisprocess::qgis_extract_output(output, "COUNT")
  }
}
JanCaha/r_package_qgis documentation built on April 4, 2024, 8:10 p.m.