makeReference: Create a reference grid from a focal area boundary.

View source: R/makeReference.R

makeReferenceR Documentation

Create a reference grid from a focal area boundary.

Description

makeReference creates a raster file large enough to contain the boundary polygon with pixels that are either aligned to the origin (default) or aligned to pixels in another raster.

Usage

makeReference(
  polyFile,
  destination,
  cellsize,
  burn = 1,
  alignTo = "origin",
  reference,
  nestingCellsize = cellsize
)

Arguments

polyFile

(character) path to a polygon shapefile (with .shp extension) containing the boundaries of the focal area in the desired projection.

destination

(character) path to a .tif file where the reference grid will be created.

cellsize

(numeric) the desired resolution or cellsize of the the reference file.

burn

(integer between 0 and 255) the value to burn into cells that fall inside the polygon

alignTo

(character) either "origin", the default, which causes cells to align to the origin of the projection such that cell boundaries fall on integer multiples of the cellsize; or "reference" in which case cells will be aligned with cells in the reference raster. If alignTo is set to "reference" than cellsize is optional and defaults to the resolution of the reference raster, but the extent is still taken from polyFile.

reference

(optional, character) if alignTo is set to "reference" than this should be the path to an existing raster file who's cell alignment we would like to match. Its projection should match that of polyFile.

nestingCellsize

(numeric) This is optional and likely not needed. If nestingCellsize is provided it must be a multiple of cellsize and the extent will be expanded out to match the extent that would be needed by this larger cellsize. This facilitates multi-scale analysis with identical extents for all scales.

Details

The new extent will be large enough to contain all the pixels within the polygon. By default it will contain pixels aligned to the origin with pixels edge coordinates that are even multiple of the cellsize.

However, if alignTo is set to "reference" and the reference argument is the path to an existing raster file than the pixels will align with the pixels in that file.

If nestingCellsize (optional and probably rarely used) is set to a multiple of cellsize, than the extent will be expanded out to match the extent that would be needed by this larger nestingCellsize. This is useful if you are working at multiple scales and want all scales to have the exact same extent. One example would be to set cellsize to 5 and nestingCellsize to 30. That will produce a reference raster with 5 meter pixels and an extent that will work well with both 5 and 30 meter pixels. Setting 30 and 30 will result in the same extent but with with 30 meter pixels.

Value

This function is called for the side effect of creating a reference tif at the destination path. It does not return anything.


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