gdal_reproject: Reproject and resample a raster

View source: R/gdal_reproject.R

gdal_reprojectR Documentation

Reproject and resample a raster

Description

This function can be used to change resolution, projection and extent of a raster.

Usage

gdal_reproject(
  infile,
  outfile,
  src_proj,
  tgt_proj,
  res,
  resampling_method = "near",
  tgt_extent,
  buffer,
  src_nodata,
  datatype = "Float32",
  return_rast = FALSE,
  overwrite = TRUE
)

Arguments

infile

Character. File path to a raster file.

outfile

Character. Output raster file path.

src_proj

Character. The source file coordinate system. Only needs to be set if you wish to reproject object and it is not specified in the infile. The coordinate systems that can be passed includes EPSG PCS and GCSes (i.e. EPSG:4296), PROJ.4 declarations (as above), or the name of a .prj file containing well known text. Starting with GDAL 2.2, if the SRS has an explicit vertical datum that points to a PROJ.4 geoidgrids, and the input dataset is a single band dataset, a vertical correction will be applied to the values of the dataset.

tgt_proj

Character. The target coordinate system. See src_proj for details. If not specified, outfile will inherit the coordinate system of infile.

res

Numeric vector containing x and y resolution. e.g. c(xres, yres). Must be specified in the units of tgt_proj.

resampling_method

Character. One of "near", "bilinear", "cubic", "cubicspline", "lanczos", "average", "mode", "max", "min", "med", "q1", "q3". See Details. Default is "near".

tgt_extent

Numeric vector containing corner coordinates specified as c(xmin, ymin, xmax, ymax). Must be specified in the units of tgt_proj.

buffer

Numeric. Add buffer (specified in units of tgt_proj). Useful for adding buffers around coasts, and for filling in small gaps within raster specified by infile.

src_nodata

Integer. The nodata value for an input file.

datatype

A character string indicating the output data type. See the gdalwarp docs for more information.

return_rast

Logical. Return RaserLayer to R?

overwrite

Logical. Should outfile be overwritten if it already exists?

Details

The resampling methods available are as follows:

  • near: nearest neighbour resampling (default, fastest algorithm, worst interpolation quality).

  • bilinear: bilinear resampling.

  • cubic: cubic resampling.

  • cubicspline: cubic spline resampling.

  • lanczos: Lanczos windowed sinc resampling.

  • average: average resampling, computes the average of all non-NODATA contributing pixels. (GDAL >= 1.10.0).

  • mode: mode resampling, selects the value which appears most often of all the sampled points. (GDAL >= 1.10.0).

  • max: maximum resampling, selects the maximum value from all non-NODATA contributing pixels. (GDAL >= 2.0.0).

  • min: minimum resampling, selects the minimum value from all non-NODATA contributing pixels. (GDAL >= 2.0.0).

  • med: median resampling, selects the median value of all non-NODATA contributing pixels. (GDAL >= 2.0.0).

  • q1: first quartile resampling, selects the first quartile value of all non-NODATA contributing pixels. (GDAL >= 2.0.0).

  • q3: third quartile resampling, selects the third quartile value of all non-NODATA contributing pixels. (GDAL >= 2.0.0).

Value

_rast A raster file is produced on disk. Additionally, if return_rast is TRUE a RasterLayer object is returned to R.


jscamac/edmaps documentation built on June 11, 2022, 1:26 a.m.