Generate scaled grid cell points

scale_grid(x, scale_factor)

Arguments

x

SpatRaster object with categorical data (factor)

scale_factor

ratio of lower (scaled) resolution to higher (original) raster resolution (resolution of lower resolution divided by resolution of higher resolution)

Value

A data frame with x and y coordinates of the lower left corner of grid cells of a scaled grid

Examples

# load categorical raster
r <- terra::rast(system.file("extdata/nlm_mid_geom_r3_sa0.tif", package = "landscapeScaling"))

# subset the raster to the lower 300 by 300 pixels
r_sub <- terra::crop(r,terra::ext(0,300,0,300))

# generate lower left corner grid points of the scaled grid cells
LL_pnts <- scale_grid(r_sub,scale_factor=15)

# print the first rows of the point coordinates data frame
head(LL_pnts)
#>    x y
#> 1  0 0
#> 2 15 0
#> 3 30 0
#> 4 45 0
#> 5 60 0
#> 6 75 0

# plot the subset raster and the scaled grid corner points
# three class color scheme
clr <- c('#332288','#44AA99','#DDCC77')
terra::plot(r_sub,col=clr,mar=c(1.5,1.5,1,1))
terra::plot(terra::vect(LL_pnts,geom=c("x","y")),pch=3,col='#EEEEEE',add=TRUE)