Skip to content

Commit

Permalink
n
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Dec 29, 2024
1 parent 69f3867 commit 7484135
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- `autocor` improved handling of NA cells for global Moran computation [#1992](https://github.com/rspatial/terra/issues/1592) by Nicholas Berryman
- `shade` is more memory-safe. [#1452](https://github.com/rspatial/terra/issues/1452) by Francis van Oordt and Chris English
- fixed bug in `rasterize` revealed when using `crop(mask=TRUE)` [#1686](https://github.com/rspatial/terra/issues/1686) by edixon1
- fixed `to_id = NA` bug in `nearest` [#1471](https://github.com/rspatial/terra/issues/1471) by Mats Blomqvist


## enhancements

Expand Down
3 changes: 2 additions & 1 deletion R/animate.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function(x, pause=0.25, main, range, maxcell=50000, n=1, ...) {
main <- names(x)
}

x <- spatSample(x, size=maxcell, method="regular", as.raster=TRUE, warn=FALSE)
# x <- spatSample(x, size=maxcell, method="regular", as.raster=TRUE, warn=FALSE)
x <- sampleRaster(x, maxcell, method="regular", replace=FALSE, ext=NULL, warn=FALSE, overview=TRUE)

if (missing(range)) {
mnmx <- minmax(x)
Expand Down
1 change: 1 addition & 0 deletions R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ setMethod("as.raster", signature(x="SpatRaster"),
#col <- rev(grDevices::terrain.colors(255))
col <- .default.pal()
}

x <- spatSample(x, maxcell, method="regular", as.raster=TRUE, warn=FALSE)
x <- as.matrix(x, wide=TRUE)
r <- range(x, na.rm=TRUE)
Expand Down
4 changes: 2 additions & 2 deletions R/sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ set_factors <- function(x, ff, cts, asdf) {
s
}

sampleRaster <- function(x, size, method, replace, ext=NULL, warn) {
sampleRaster <- function(x, size, method, replace, ext=NULL, warn, overview=FALSE) {
# hadWin <- hasWin <- FALSE
if (!is.null(ext)) {
# hasWin <- TRUE
Expand All @@ -413,7 +413,7 @@ sampleRaster <- function(x, size, method, replace, ext=NULL, warn) {
if (length(size) > 1) {
x@pntr <- x@pntr$sampleRowColRaster(size[1], size[2], warn[1])
} else {
x@pntr <- x@pntr$sampleRegularRaster(size)
x@pntr <- x@pntr$sampleRegularRaster(size, overview)
}
} else if (method == "random") {
x@pntr <- x@pntr$sampleRandomRaster(size, replace, .seed())
Expand Down

0 comments on commit 7484135

Please sign in to comment.