From 9673041713c6bdaedd9e74f10838155682738424 Mon Sep 17 00:00:00 2001 From: rhijmans Date: Wed, 31 Jan 2024 07:05:58 +0100 Subject: [PATCH] n --- NEWS.md | 2 ++ R/tiles.R | 2 +- man/makeTiles.Rd | 7 ++++++- man/vrt.Rd | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index ee7ab5e7c..047bbd468 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ - `polys` argument "alpha" was ignored if a single color was used. [#1413](https://github.com/rspatial/terra/issues/1413) by Derek Friend - `query` ignore the "vars" argument if all rows were selected. [#1398](https://github.com/rspatial/terra/issues/1398) by erkent-carb. - `spatSample` ignored "replace=TRUE" with random sampling, na.rm=TRUE, and a sample size larger than the non NA cells. [#1411](https://github.com/rspatial/terra/issues/1411) by Babak Naimi +- `spatSample` sometimes returned fewer values than requested and available for lonlat rasters. [#1396](https://github.com/rspatial/terra/issues/1396) by Márcia Barbosa. ## enhancements @@ -26,6 +27,7 @@ - `prcomp` method [#1361](https://github.com/rspatial/terra/issues/1361#issuecomment-1860311029) by Jakub Nowosad - `add_box` to add a box around the map. The box is drawn where the axes are, not around the plotting region. +- `getTileExtents` provides the extents of for tiles. These may be used in parallelization. See [#1391](https://github.com/rspatial/terra/issues/1391) by Alex Ilich. # version 1.7-65 diff --git a/R/tiles.R b/R/tiles.R index 0de7f3167..a3316719e 100644 --- a/R/tiles.R +++ b/R/tiles.R @@ -26,7 +26,7 @@ setMethod("makeTiles", signature(x="SpatRaster"), setMethod("getTileExtents", signature(x="SpatRaster"), - function(x, y, extend=FALSE, na.rm=FALSE, buffer=0) { + function(x, y, extend=FALSE, buffer=0) { opt <- spatOptions(filename="") if (inherits(y, "SpatRaster")) { diff --git a/man/makeTiles.Rd b/man/makeTiles.Rd index 991c60db4..d07fab5b3 100644 --- a/man/makeTiles.Rd +++ b/man/makeTiles.Rd @@ -27,7 +27,7 @@ Divide a SpatRaster into "tiles". The cells of another SpatRaster (normally with \arguments{ \item{x}{SpatRaster} - \item{y}{SpatRaster, SpatVector, or numeric} + \item{y}{SpatRaster or SpatVector defining the zones; or numeric specifying the number of rows and columns for each zone (1 or 2 numbers if the number of rows and columns is not the same)} \item{filename}{character. Output filename template. Filenames will be altered by adding the tile number for each tile} \item{extend}{logical. If \code{TRUE}, the extent of \code{y} is expanded to assure that it covers all of \code{x}} \item{na.rm}{logical. If \code{TRUE}, tiles with only missing values are ignored} @@ -51,6 +51,11 @@ character (filenames) or matrix (extents) r <- rast(ncols=100, nrows=100) values(r) <- 1:ncell(r) x <- rast(ncols=2, nrows=2) + +getTileExtents(r, x) +getTileExtents(r, x, buffer=3) + + filename <- paste0(tempfile(), "_.tif") ff <- makeTiles(r, x, filename) ff diff --git a/man/vrt.Rd b/man/vrt.Rd index a86c18db4..affb7f9f5 100644 --- a/man/vrt.Rd +++ b/man/vrt.Rd @@ -17,7 +17,7 @@ Create a Virtual Raster Dataset (VRT) from a collection of file-based raster dat } \arguments{ - \item{x}{character. Filenames of raster "tiles". See \code{\link{tiles}}} + \item{x}{character. Filenames of raster "tiles". That is, files that have data for, typically non-overlapping, sub-regions of an raster. See \code{\link{makeTiles}}} \item{filename}{character. output VRT filename} \item{options}{character. All arguments as separate vector elements. Options as for \href{https://gdal.org/programs/gdalbuildvrt.html}{gdalbuildvrt}} \item{overwrite}{logical. Should \code{filename} be overwritten if it exists?}