Skip to content

Commit

Permalink
r
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Feb 7, 2024
1 parent 7b1b957 commit be05d31
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions R/rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ setMethod("rast", signature(x="missing"),


rast_from_image <- function(x) {
# list should represent an "image"
# list representing an "image"
if (! all(dim(x$z) == c(length(x$x), length(x$y)))) {
error("rast", '"z" does not have the right dimensions')
}
Expand All @@ -95,17 +95,14 @@ rast_from_image <- function(x) {
if (dx > 0.01 | dy > 0.01) {
error("rast", "data are not on a regular grid")
}
if (xmn > -360.1 & xmx < 360.1 & ymn > -90.1 & ymx < 90.1) {
crs <- "+proj=longlat +datum=WGS84"
} else {
crs <- ""
}
# if (xmn > -360.1 & xmx < 360.1 & ymn > -90.1 & ymx < 90.1) {
# crs <- "+proj=longlat +datum=WGS84"
# } else {
# crs <- ""
# }
x <- t(x$z)
x <- x[nrow(x):1, ]

r <- rast(nrows=nrow(x), ncols=ncol(x), extent=ext(xmn, xmx, ymn, ymx), crs=crs)
values(r) <- as.vector(t(x))
r
rast(x, extent=ext(xmn, xmx, ymn, ymx), crs="")
}


Expand Down

0 comments on commit be05d31

Please sign in to comment.