Learn R Programming

TroublemakeR (version 0.0.1)

write_cell_param: Write cell parameters

Description

This function takes a Raster object, uses its values as a parameter and writes them to a .dat file. The file will be written to the location specified by the name argument. If the file already exists, it will be overwritten. The file format is plain text, with each line terminated by a newline character.

Usage

write_cell_param(
  Rasterparam,
  parameter,
  default = NULL,
  name = "Problem",
  verbose = FALSE
)

Value

.dat file. This function is used for the side-effect of writing values to a file.

Arguments

Rasterparam

A Raster object with the values for the parameter

parameter

The name of the parameter to use

default

The value of the default value for the parameter if there is one, otherwise keep it as NULL

name

The name of the output file

verbose

Logical whether messages will be written while the function is generating calculations, defaults to FALSE

Examples

Run this code

library(terra)

A <- TroublemakeR::Current |> terra::unwrap()
A <- A[[1]]

write_cell_param(Rasterparam = A, parameter = "Suitability", name = "Problem")

 write_cell_param(Rasterparam = A, parameter = "Carbon", default = 1,
 name = "Problem")

 write_cell_param(Rasterparam = A, parameter = "Cost", default = 0,
 name = "Problem")

 file.remove("Problem.dat")

Run the code above in your browser using DataLab