Learn R Programming

rdwplus (version 1.0.1)

convert_to_integer: Convert a raster to integer format

Description

Given a raster in float, double or any other format, this function will convert it to integer format. This can be important because it is often an unstated requirement of GRASS modules such as the one for zonal statistics.

Usage

convert_to_integer(x, out)

Value

Nothing. A raster with the name out will be added to the current GRASS mapset.

Arguments

x

A raster layer in the current GRASS mapset.

out

Name of the output raster. Avoid names with hyphens.

Examples

Run this code
# Will only run if GRASS is running
if(check_running()){

# Load data set
dem <- system.file("extdata", "dem.tif", package = "rdwplus")

# Set environment 
set_envir(dem)

# Make an integer-valued version of 'dem.tif'
convert_to_integer("dem.tif", "int_dem.tif")

# Compare
plot_GRASS("dem.tif")
plot_GRASS("int_dem.tif")

}

Run the code above in your browser using DataLab