Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Nov 11, 2023
1 parent 14bf199 commit 83ef6f9
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
https://stackoverflow.com/questions/77304534/rspatial-terraflip-error-when-flipping-a-multi-layer-spatrast-object)
- SpatRaster now correctly handles `NA & FALSE` and `NA | TRUE` [#1316](https://github.com/rspatial/terra/issues/1316) by John Baums
- `set.names` wasn't working properly for SpatRasterDataset or SpatRasterCollection [#1333](https://github.com/rspatial/terra/pull/1333) by Derek Friend
- `extract` with argument "layer" not NULL shifted the layers [#1332](https://github.com/rspatial/terra/issues/1332) by Ewan Wakefield


## enhancements

Expand Down
2 changes: 1 addition & 1 deletion R/RGB.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ rgb2col <- function(x, value, stretch=NULL, grays=FALSE, NAzero=FALSE, filename=
}

v <- cbind(id=1:ncell(x), values(x))
v <- terra:::median_cut(stats::na.omit(v))
v <- median_cut(stats::na.omit(v))

a <- aggregate(v[,-c(1:2)], list(v[,1]), median)
# if (n==3) {
Expand Down
2 changes: 1 addition & 1 deletion R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ as.data.frame.SpatRaster <- function(x, row.names=NULL, optional=FALSE, xy=FALSE
if (xy) idv <- c("x", "y", idv)
if (cells) idv <- c("cell", idv)
nms <- names(x)
d <- reshape(d, direction="long", idvar=idv, varying=nms, v.names="values")
d <- stats::reshape(d, direction="long", idvar=idv, varying=nms, v.names="values")
d$time <- nms[d$time]
names(d)[names(d) == "time"] <- "layer"
}
Expand Down
6 changes: 3 additions & 3 deletions R/k_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setMethod("k_means", signature(x="SpatRaster"),
if (ncell(x) <= maxcell) {
v <- na.omit(as.matrix(x))
omit <- as.vector(attr(v, "na.action"))
km <- kmeans(v, centers=centers, ...)
km <- stats::kmeans(v, centers=centers, ...)
out <- rast(x, nlyr=1)
if (is.null(omit)) {
values(out) <- km$cluster
Expand All @@ -34,8 +34,8 @@ setMethod("k_means", signature(x="SpatRaster"),
}
vec
}
v <- na.omit(spatSample(x, maxcell, "regular"))
km <- kmeans(v, centers=centers, ...)$centers
v <- unique(na.omit(spatSample(x, maxcell, "regular")))
km <- stats::kmeans(v, centers=centers, ...)$centers
out <- predict(x, km, fun=pkmeans, filename=filename, overwrite=overwrite, wopt=wopt)
}
out
Expand Down
2 changes: 1 addition & 1 deletion R/plot_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ prettyNumbs <- function(x, digits) {
if (ncell(x) > 1.1 * maxcell) {
if (inherits(alpha, "SpatRaster")) {
if (nlyr(alpha) > 1) {
alpha <- alpha[[y]]
alpha <- alpha[[1]]
}
alpha <- spatSample(alpha, maxcell, method="regular", as.raster=TRUE, warn=FALSE)
}
Expand Down
2 changes: 1 addition & 1 deletion R/zonal.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ setMethod("zonal", signature(x="SpatRaster", z="SpatVector"),
}
if (as.polygons | wide) {
nms <- names(v)
v <- reshape(v, direction="wide", idvar=nms[1], timevar=nms[2])
v <- stats::reshape(v, direction="wide", idvar=nms[1], timevar=nms[2])
names(v) <- gsub("count.", "", names(v))
v[is.na(v)] <- 0
rownames(v) <- NULL
Expand Down
2 changes: 2 additions & 0 deletions man/distance.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
\alias{distance,SpatVector,SpatVector-method}
\alias{distance,matrix,matrix-method}
\alias{distance,matrix,missing-method}
\alias{distance,data.frame,data.frame-method}
\alias{distance,data.frame,missing-method}

\title{Geographic distance}

Expand Down
1 change: 1 addition & 0 deletions man/time.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
\alias{time<-}
\alias{time<-,SpatRaster-method}
\alias{time<-,SpatRasterDataset-method}
\alias{has.time,SpatRasterDataset-method}
\alias{time,SpatRaster-method}
\alias{time,SpatRasterDataset-method}
\alias{timeInfo}
Expand Down

0 comments on commit 83ef6f9

Please sign in to comment.