This function calculates and extracts the resolution (in metres) of a single pixel (centre) from a raster file.
It determines the central pixel of the raster, crops to that single pixel, and
returns its resolution in the specified CRS. Uses terra::rast()
, terra::ext()
, terra::crop()
, and terra::project()
to perform these operations.
Value
numeric A vector of length two representing the resolution of the single pixel in metres in the specified CRS.
Details
The function first calculates the extent and resolution of the raster, identifies the central pixel, and crops the raster to that pixel. It then projects the cropped raster to the specified CRS and calculates the resolution of the single pixel.
See also
Other spacehakr:
ngr_spk_ext_raster()
,
ngr_spk_gdalwarp()
,
ngr_spk_odm()
,
ngr_spk_poly_to_points()
Examples
path <- system.file("extdata", "test.tif", package = "ngr")
crs_out <- "EPSG:32609"
ngr_spk_res(path, crs_out)
#> Error: [rast] filename is empty. Provide a valid filename