The recommended, batteries-included entry point. ck_warp() takes the
grid-defining gdalwarp options as named arguments (t_srs, te, tr,
ts, r, bands), layers on cptkirk's performance defaults (multi-threaded
warp, generous warp memory and block cache, SKIP_NOSOURCE), and streams
only the pixels the request touches over async-tiff before handing the
warp to GDAL via gdalraster::warp(). For a faithful, defaults-free sibling
of gdalraster::warp(), see warp_remote().
Usage
ck_warp(
src,
dst,
t_srs = NULL,
te = NULL,
te_srs = NULL,
tr = NULL,
ts = NULL,
tap = TRUE,
r = c("near", "bilinear", "cubic", "cubicspline", "lanczos", "average", "rms", "mode",
"max", "min", "med", "q1", "q3", "sum"),
bands = NULL,
cl_arg = character(0),
num_threads = "ALL_CPUS",
warp_memory = "auto",
cache_max = "auto",
co = c("COMPRESS=DEFLATE", "TILED=YES", "NUM_THREADS=ALL_CPUS", "BIGTIFF=IF_SAFER"),
config = NULL,
skip_nosource = TRUE,
overview = NULL,
margin = 8L,
io_concurrency = 16L,
max_bytes = NULL,
sanitise = TRUE
)Arguments
- src
Path/URL to a source GeoTIFF / COG, a
cog_source()handle, or a character vector of several sources to mosaic (each tile's overlapping window is fetched and the set is reprojected/mosaicked in one warp; non-overlapping tiles are skipped). Passing acog_source()reuses its already-open handle, skipping the metadata re-read – worthwhile when warping many AOIs from the same source.- dst
Output filename (a regular path, a
/vsimem/path, or anything GDAL can write). The format is inferred by GDAL or set with-ofincl_arg.- t_srs
Target SRS (e.g.
"EPSG:3857"). IfNULL, the source CRS is used (no reprojection).- te
Target extent
c(xmin, ymin, xmax, ymax), inte_srsif given, otherwise int_srs. When supplied this is the AOI that drives the fetch.- te_srs
SRS of
te(defaults tot_srs).- tr
Target resolution
c(xres, yres)in target CRS units. Takes precedence overts: if both are given,tsis ignored (with a warning).- ts
Target size
c(width, height)in pixels. Ignored iftris also supplied.- tap
If
TRUE(default) andtris given, align output pixel boundaries to thetrgrid (gdalwarp-tap), anchored at the CRS origin, so outputs at the same resolution share a grid and stack cleanly. This snaps the output extent outward, so it is no longer exactlyte. No effect withtsor on the copy path. An explicit-tapincl_argis always honoured. (warp_remote()never adds this; pass-tapyourself.)- r
Resampling method, one of
"near"(default),"bilinear","cubic","cubicspline","lanczos","average","rms","mode","max","min","med","q1","q3","sum". Matched withrlang::arg_match(), so a typo reports the valid set. (A method added by a newer GDAL than this list knows can still be passed viacl_arg.)- bands
1-based source bands to read (default: all). Subsetting happens during the fetch, so only those bands' bytes are streamed.
- cl_arg
Character vector of extra raw
gdalwarpflags, forwarded verbatim togdalraster::warp()(e.g.c("-et", "0")). These are merged with the flags cptkirk builds from the named arguments above.- num_threads
Value for GDAL's warp
NUM_THREADSwarp option and theGDAL_NUM_THREADSconfig (default"ALL_CPUS"), parallelising the resampling computation and GeoTIFF (de)compression.NULLsets neither, deferring to the ambientGDAL_NUM_THREADS(env / session).- warp_memory
Warp working memory in MB (GDAL
-wm)."auto"(default) uses ~25% of system RAM, clamped to 256-2048 MB (bigger means fewer, larger chunks);NULLdefers to GDAL's own default; a number sets it explicitly.- cache_max
GDAL block cache in MB for this call.
"auto"(default) uses ~25% of RAM, clamped to 256-2000 MB;NULLdefers to the ambientGDAL_CACHEMAX(env /gdalraster::set_config_option()); a number sets it explicitly. Any value is restored to the previous setting afterwards.- co
GDAL output creation options, defaulting to a cloud-friendly GeoTIFF set:
c("COMPRESS=DEFLATE", "TILED=YES", "NUM_THREADS=ALL_CPUS", "BIGTIFF=IF_SAFER")— losslessly compressed, tiled (so the output can be re-read by cptkirk and any other COG reader), compressed in parallel, and promoted to BigTIFF when it might exceed 4 GB. Pass your own to override (e.g. add"PREDICTOR=2"for integer data, or"COMPRESS=ZSTD"on a GDAL built with it), orNULLfor no creation options. These target the GTiff/COG drivers; setcoyourself for other output formats.- config
Named character vector / list of extra GDAL config options to set for the duration of the call (restored on exit).
- skip_nosource
If
TRUE(default), passSKIP_NOSOURCE=YES+INIT_DESTso the warper skips output chunks with no source coverage (e.g. nodata margins from reprojection). No effect when output is fully covered. Ignored on the copy fast-path.- overview
Force a 1-based IFD/overview level instead of auto-selecting from the output resolution.
1= full resolution.- margin
Source-pixel margin added around the computed window to cover the resampling kernel and reprojection slop (default 8).
- io_concurrency
Number of concurrent tile reads – the width of the single global fetch pool shared across all source tiles. Default 16, which suits object stores that throttle around that many simultaneous range requests (e.g. S3 / source.coop). Raise (24-32) on a fast, stable link; lower if a store rate-limits.
- max_bytes
Safety ceiling (bytes) on the staged in-memory window (
width * height * bands * <native dtype bytes>).NULL(default) uses ~1/3 of system RAM. It only guards against the foot-gun of warping a whole large multi-band raster at native resolution; narrow the request, coarsentr/ts, or raise this to allow it.- sanitise
If
TRUE(default), validate the warp arguments against a tiny metadata-derived stand-in before fetching, so a bad CRS, resampling method, creation option or unknown flag fails in milliseconds instead of after a remote read. SetFALSEto skip the check.
Details
Every actual resampling / reprojection decision is GDAL's; cptkirk only sizes and saturates the fetch.
See also
warp_remote() for the thin gdalraster::warp() sibling.
