pixel_dim: Estimating metric dimensions of pixels in raster object

View source: R/pixel_dim.R

pixel_dimR Documentation

Estimating metric dimensions of pixels in raster object

Description

Pixel dimension in raster objects (class ⁠Raster*⁠) in projected space.

For non projected rasters, the bounding boxes will be reprojected to UTM coordinates for the calculation of height (latitude) and width (longitude). For projected rasters, the calculation will be directly done in the units of the respective spacial reference system.

Usage

pixel_dim(raster, ...)

## S3 method for class 'SpatRaster'
pixel_dim(raster, projected = FALSE, ...)

Arguments

raster

An object of class ⁠Raster*⁠.

...

Further arguments passed among methods (Not yet used).

projected

Logical value indicating whether the coordinates of raster input are projected or not.

Value

A named vector with the estimated height (latitude) and width (longitude) of pixels either in meters for non-projected rasters or in the own spacial units for projected ones.

Author(s)

Lukas Trübenbach and Miguel Alvarez (kamapu78@gmail.com).

Examples

## Determine resolution
r <- terra::rast(system.file("ex/elev.tif", package="terra"))
pixel_dim(r)

## More appropriate for projected coordinates
pixel_dim(r, projected = TRUE)

kamapu/spatialist documentation built on Jan. 10, 2025, 6:59 p.m.