Authors: Andrew Plowright
License: GPL 3
knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/", fig.height = 4, fig.width = 6 ) knitr::opts_knit$set( global.par = TRUE )
par(mar = c(3,3,1,0.1))
This package provides tools for working with tiled geospatial datasets.
The latest release of TileManager is a complete refactor of the old library, which used the obsolete raster and sp packages. The new version uses terra and sf instead. Although the structure of the tileScheme class remains similar, any spatial outputs from this library now use sf formats.
Furthermore, tileScheme objects are now saved to the Geopackage format instead of SHP files.
Use the tileScheme function to create a set of tiles from a Raster or Extent object.
library(TileManager) library(terra) # Load a test raster chm <- rast(system.file("ex/chm.tif", package="TileManager")) # Generate a tile scheme ts <- tileScheme(chm, dim = c(30,30), buffer = 5) plot(chm) plot(ts, add = T)
Use the remove_empty argument to drop tiles with no Raster values.
ts <- tileScheme(chm, dim = c(20,20), buffer = 2.5, remove_empty = TRUE) plot(chm) plot(ts, add = T)
Other handy features:
origin argument can be used to force the tile scheme to snap to a pair of coordinates.spill argument controls whether or not the buffers extent beyond the input's original extent.cells argument, they can be defined by a number of Raster cells.Non-overlapping buffers (often abbreviated to nbuffs) are useful for re-assembling tiled data. Essentially, they preserve buffers only where they do not overlap onto neighboring tiles (i.e.: along the edge of the tile scheme). This allows you to recombine tiles without worrying about overlapping areas and without losing any information along the data edges.
In the example below:
plot(chm, xlim = c(439871, 439960), ylim = c(5526705, 5526756), xlab = "", ylab = "", legend = FALSE) plot(ts, add = T)
Some useful methods are provided for subsetting the tile scheme, or for converting it into other formats.
Get buffers as a sf object:
ts[["buffs"]]
Subset a specific tile by name, number or row/col:
# By name ts["R2C2"] # By number ts[7] # By row/col ts[2,3]
Subset entire rows or columns:
# One row ts[4,] # Multiple columns ts[,2:3]
The tile scheme can be saved as a single Geopackage. In this case, tiles, buffs and nbuffs will all be written to separate tables. Other metadata (such as the buffer size) are written to a metadata table.
# Create tile scheme ts <- tileScheme(chm, dim = c(30,30), buffer = 5) # Save tile scheme tileSave(ts, "C:/myfiles/tilescheme.gpkg") # Load tile scheme ts <- tileLoad("C:/myfiles/tilescheme.gpkg")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.