meteo (version 0.1-5)

tiling: 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(filename,tilesize=500,overlapping=50, aspoints= FALSE, asfiles=FALSE,tilename="tile", format="GTiff", tiles_folder=paste(getwd(),'tiles',sep='/'), parallel.processing=FALSE, cpus=6)

Arguments

filename
raster object, SpatialPixels* object, SpatialGrid* object or file path of raster object stored on the disk (can be read via readGDAL), for more details see raster. The resolution of object should be the same in x and y direction.
tilesize
tile size in cells in x direction. nx = ny is assumed, total number of tile cells is tilesize by tilesize.
overlapping
overlapping cells in each direction
aspoints
if TRUE tiles are in form of SpatialPointsDataFrame
asfiles
if TRUE tiles are stored on local drive as raster objects
tilename
prefix given to file names
format
file format, see writeRaster
tiles_folder
folder to be created for tiles storage
parallel.processing
if TRUE parralel processing is performed via sfLapply
cpus
number of proccesing units

Value

SpatialPointsDataFrame format if aspoints=TRUE

See Also

pred.strk

Examples

Run this code
data(regdata) 
str(regdata@sp) # DEM and TWI data for Serbia at 1 km resolution
dem=regdata@sp['dem']
library(sp)
spplot(dem,  col.regions=bpy.colors() )

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

image(dem)
points(tiles[[1]] , pch='-' ,col ='green')
points(tiles[[2]], pch='.')

str(tiles[[1]])

Run the code above in your browser using DataCamp Workspace