Learn R Programming

reproducible (version 3.2.1)

prepInputsCOG: Fast spatial subsetting of Cloud Optimized GeoTiff (COG) files

Description

An alternative fast-path inside prepInputs() for remote Cloud Optimized GeoTiffs. When a URL points to a COG and the user has specified a spatial subsetting argument (to, cropTo, or maskTo), this function reads only the spatial window of interest via GDAL's /vsicurl/ virtual filesystem — no full-file download is needed. The returned SpatRaster is passed back to prepInputs where the normal postProcess step (mask, reproject, write) completes the pipeline.

This function is called automatically from inside prepInputs() when getOption("reproducible.useCOG") is TRUE (the default). It can also be called directly.

Usage

prepInputsCOG(url, verbose = getOption("reproducible.verbose", 1), ...)

Value

A SpatRaster windowed to the bounding box of the to/cropTo/maskTo

object (in the COG's own CRS), or the character string "NULL" if any pre-condition fails (not HTTP, no spatial arg, network error, empty window, etc.).

Arguments

url

Character. An HTTP(S) URL pointing to a GeoTiff file.

verbose

Numeric or Logical. Verbosity level.

...

Passed through; expected to contain at least one of to, cropTo, or maskTo (a spatial object defining the area of interest).

See Also

prepInputs(), prepInputsWithTiles()