nh_crop: Crop extra rows/columns from all sides of a raster

View source: R/nh_crop.R

nh_cropR Documentation

Crop extra rows/columns from all sides of a raster

Description

This function will reduce the extent of a raster, by removing rows/columns from all sides which do not have any non-NA cells with a value greater than zero. One buffer row/column is left on each side.

Usage

nh_crop(rast)

Arguments

rast

input raster

Value

SpatRaster

Author(s)

David Bucklin

Examples

## Not run: 
rast <- terra::rast("_data/species/ambymabe/outputs/model_predictions/ambymabe_20171018_130837.tif")
values(rast) <- ifelse(values(rast) > 0.3, 1, NA)
rast.crop <- nh_crop(rast)

# should be TRUE
sum(values(rast), na.rm=T) == sum(values(rast.crop), na.rm=T)

## End(Not run)

VANatHeritage/nhSDM documentation built on Feb. 1, 2024, 6:39 a.m.