Skip to content

Commit

Permalink
support gdalnara format
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Dec 31, 2023
1 parent 487223e commit a2a4824
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ximage
Title: Draw Images of Raster Data and Related Adornments
Version: 0.0.0.9006
Version: 0.0.0.9007
Authors@R:
person("Michael D.", "Sumner", , "mdsumner@gmail.com", role = c("aut", "cre"))
Description: Draw images easily and as if doing that was considered desirable or
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ximage dev

* `image()` now works with list output from gdalnara (same as gdal_raster_image but with nativeRaster).

* Added suport for `xcontour()` for the output output of `gdal_raster_data()` in {vapour}.

* `ximage()` can now plot sf::gdal_read objects.
Expand Down
6 changes: 6 additions & 0 deletions R/ximage.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ ximage.list <- function(x, extent = NULL, zlim = NULL, add = FALSE, ..., xlab =
ximage_sf_data(x, extent = extent, zlim = zlim, add = add, ..., xlab = xlab, ylab = ylab, col = col)
return(invisible(x))
}

## here validate that we have extent, dimension as attributes, otherwise just see if it's a matrix
attrs <- attributes(x)
if (!is.null(attrs$extent) && is.null(extent)) extent <- attrs$extent
Expand Down Expand Up @@ -130,6 +131,11 @@ ximage.list <- function(x, extent = NULL, zlim = NULL, add = FALSE, ..., xlab =
}
}

if (inherits(x[[1]], "nativeRaster")) {
ximage(x[[1L]], extent = extent, zlim = zlim, add = add, ..., xlab = xlab, ylab = ylab, col = col)
return(invisible(x))
}

if (length(x) %in% c(3, 4)) {
ximage(aperm(array(unlist(x), c(dimension[1:2], 3)), c(2, 1, length(x))),
extent = extent, zlim = zlim, add = add, ..., xlab = xlab, ylab = ylab, col = col)
Expand Down

0 comments on commit a2a4824

Please sign in to comment.