Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Dec 5, 2023
1 parent 315295a commit a24b6dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 9 additions & 1 deletion R/plot_2rasters.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
nly <- nlyr(y)

maxnl <- max(1, round(maxnl))
nl <- max(nlx, nly)
nl <- min(max(nlx, nly), maxnl)
if (nl > maxnl) {
nl <- maxnl
if (nlx > maxnl) {
Expand All @@ -26,6 +26,14 @@
}
}

if (nlx < nly) {
x <- x[[rep_len(1:nlx, nly)]]
nlx <- nly
} else if (nly < nlx) {
y <- y[[rep_len(1:nly, nlx)]]
nly <- nlx
}


if (missing(main)) {
main <- ""
Expand Down
12 changes: 8 additions & 4 deletions man/princomp.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ x <- predict(r, pca)
# use "index" to get a subset of the components
p <- predict(r, pca, index=1:2)

### use princomp directly (or use prcomp instead)
pca <- princomp(r)
# may need to use sampling with a large raster
### use princomp directly
pca2 <- princomp(values(r), fix_sign = TRUE)
p2 <- predict(r, pca2)

### may need to use sampling with a large raster
### here with prcomp instead of princomp
sr <- spatSample(r, 100000, "regular")
pca <- prcomp(sr)
pca3 <- prcomp(sr)
p3 <- predict(r, pca3)
}

\keyword{spatial}
Expand Down

0 comments on commit a24b6dd

Please sign in to comment.