|
71 | 71 | }
|
72 | 72 |
|
73 | 73 |
|
74 |
| -.as.raster.continuous <- function(out, x, type) { |
| 74 | +.as.raster.continuous <- function(out, x, type, Z=NULL) { |
| 75 | + |
| 76 | + if (is.null(Z)) { |
| 77 | + Z <- as.matrix(x, wide=TRUE) |
| 78 | + Z[is.nan(Z) | is.infinite(Z)] <- NA |
| 79 | + } |
75 | 80 |
|
76 | 81 | Z <- as.matrix(x, wide=TRUE)
|
77 | 82 | Z[is.nan(Z) | is.infinite(Z)] <- NA
|
78 |
| - |
| 83 | + Z[] <- round(Z, 12) |
| 84 | + |
79 | 85 | # loss of precision
|
80 | 86 | # z <- stats::na.omit(round(as.vector(Z), 12))
|
81 | 87 | z <- stats::na.omit(as.vector(Z))
|
|
87 | 93 | return(out)
|
88 | 94 | }
|
89 | 95 |
|
90 |
| - uzi <- round(unique(z), 12) |
| 96 | + uzi <- unique(z) |
91 | 97 |
|
92 | 98 | if (type == "depends") {
|
93 | 99 | if (length(uzi) < 9) {
|
94 |
| - return (.as.raster.classes(out, x)) |
| 100 | + return (.as.raster.classes(out, x, Z=Z)) |
95 | 101 | }
|
96 | 102 | } else if ((length(uzi) == 1) && is.null(out$range)) {
|
97 |
| - return (.as.raster.classes(out, x)) |
| 103 | + return (.as.raster.classes(out, x, Z=Z)) |
98 | 104 | }
|
99 | 105 |
|
100 | 106 | if (is.null(out$range)) {
|
@@ -146,10 +152,12 @@ prettyNumbs <- function(x, digits) {
|
146 | 152 | gsub("\\.$", "", x)
|
147 | 153 | }
|
148 | 154 |
|
149 |
| -.as.raster.classes <- function(out, x, ...) { |
| 155 | +.as.raster.classes <- function(out, x, Z=NULL, ...) { |
150 | 156 |
|
151 |
| - Z <- as.matrix(x, wide=TRUE) |
152 |
| - Z[is.nan(Z) | is.infinite(Z)] <- NA |
| 157 | + if (is.null(Z)) { |
| 158 | + Z <- as.matrix(x, wide=TRUE) |
| 159 | + Z[is.nan(Z) | is.infinite(Z)] <- NA |
| 160 | + } |
153 | 161 | if (all(is.na(Z))) {
|
154 | 162 | #out$values = FALSE
|
155 | 163 | out$range <- c(NA, NA)
|
|
0 commit comments