tiling: Tiling raster or Spatial-class Grid or Pixels object

View source: R/tiling.R

tilingR Documentation

Tiling raster or Spatial-class Grid or Pixels object

Description

Tiling raster or Spatial-class Grid or Pixels (data frame) object to smaller parts with optional overlap.

Usage

tiling(rast,
       tilesize=500,
       overlapping=50,
       aspoints= NA, 
       asfiles=FALSE,
       tilename="tile",
       tiles_folder='tiles',
       parallel.processing=FALSE,
       cpus=6,
       ...)

Arguments

rast

SpatRaster, SpatialPixels* object, SpatialGrid* object or file path to raster object stored on the disk (can be read via rast), for more details see SpatRaster. The resolution of the raster should be the same in x and y direction.

tilesize

integer or vector; tile size in number of cells. Can be a vector of tilesize in x and y direction. Total number of tile cells is tilesize[1] x tilesize[2].

overlapping

integer or vector; overlapping in number of cells. Can be a vector of overlapping in x and y direction.

aspoints

character; Posiible values are sf, terra sp. If specified, tiles are returned in form of points as sf-class, SpatVector or SpatialPointsDataFrame.

asfiles

boolean; if TRUE tiles are stored on local drive as raster objects.

tilename

character; prefix given to file names

tiles_folder

character; destination folder where tiles will be stored. If doesn't exist, the folder will be created.

parallel.processing

boolean; if TRUE parralel processing is performed via snowfall-calculation, sfLapply function.

cpus

integer; number of proccesing units.

...

character; additional arguments for for writing files, see writeRaster.

Value

The list of tiles in SpatRaster-class format or in sf-class, SpatVector or SpatialPointsDataFrame format if aspoints=TRUE.

Author(s)

Milan Kilibarda kili@grf.bg.ac.rs

See Also

pred.strk

Examples

library(sp)
demo(meuse, echo=FALSE)
rast <- terra::rast(meuse.grid[, "dist"])

# tiling dem in tiles 250x250 with 25 cells overlap
tiles = tiling(rast,
               tilesize=20,
               overlapping=5,
               aspoints=TRUE)
# number of tiles
length(tiles)


plot(rast)
plot(tiles[[1]] , pch='-' ,col ='green', add=TRUE)
plot(tiles[[2]], pch='.', add=TRUE)


str(tiles[[1]])


meteo documentation built on May 29, 2024, 6:13 a.m.

Related to tiling in meteo...