addOverviews: Function to add overviews to an image file

View source: R/addOverviews.R

addOverviewsR Documentation

Function to add overviews to an image file

Description

This function creates overviews (aka pyramids) with compressed copies of the data from a raster at multiple coarser resolutions. They are saved in a side car file with the extension ".ovr" appended to the original file's full name (e.g. "dem.tif.ovr" would contain the overviews for "dem.tif"). Overview are used by GIS software to display the raster file more quickly when zoomed out. They are especially useful for large files.

Usage

addOverviews(
  x,
  clean = FALSE,
  compression = "LZW",
  method = "nearest",
  overviews = c(2, 4, 8, 16, 32, 64, 128, 256),
  readonly = TRUE
)

Arguments

x

The path to a TIFF or other raster file.

clean

Defaults to FALSE; set to TRUE to remove instead of add overviews.

compression

The style of compression used in the overviews options are: "LZW" (the default), "DEFLATE", and "JPEG".

method

(character) the resampling method one of "nearest", "average", "gauss", "cubic", "cubicspline", "lanczos", "average_mp", "average_magphase", or "mode". It is passed to gdaladdo check there for details. "near" is also accepted and silently converted to, "nearest".

overviews

Overview levels to use. See gdaladdo

readonly

if TRUE x will not be modified and overviews will be written to an external file. See gdaladdo -ro

Details

Generally the default arguments are good but you may want to change the method to "average" for continuous raster files and possibly to "mode" for categorical files. For continuous files, especially imagery, if you are OK with lossy compression in the overviews you may change the compression to "JPEG" which should result in smaller files.

addOveriews is a convenience wrapper to the gdaladdo utility. addOverviews() sets reasonable defaults, only some of which can be overridden.

Value

addOverviews creates an additional ".ovr" file alongside x with overview information. It does not return anything.


ethanplunkett/rasterPrep documentation built on Sept. 17, 2024, 1:05 p.m.