fixFactorRaster: Fix a misfactored raster

View source: R/utils.R

fixFactorRasterR Documentation

Fix a misfactored raster

Description

Creates a correctly-factored version of a misfactored SpatRast object.

Usage

fixFactorRaster(raster = NULL)

Arguments

raster

The faulty factor SpatRast object.

Details

terra seems to have issues loading some factor raster files. For instance, a factor raster made using the ArcGIS 'Polygon to Raster' tool and then loaded with terra::rast() will only show a 'Count' field instead of the field specified in 'Polygon to Raster'. Additionally, the 'Count' value assigned to each cell appears to be misleveled by 1 row when inspected in the raster's terra::cats() table. The fixFactorRaster() function attempts to take a faulty raster and map its values to the correct field, as it still exists in the terra::cats() table.


tabrasel/WetlandTools documentation built on Dec. 20, 2024, 8:50 a.m.