Skip to content

Commit

Permalink
Merge pull request #175 from r-spatial/stars_0.5.5
Browse files Browse the repository at this point in the history
as_qgis_argument.stars_proxy(): also support stars < 0.6-0
  • Loading branch information
florisvdh authored Sep 15, 2023
2 parents f279c30 + 2c3404b commit 1dcf18e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/compat-stars.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,19 @@ as_qgis_argument_stars <- function(x, spec = qgis_argument_spec(), use_json_inpu
}
}
# we can only check for total band number; they have no names in stars
stars_ok <- utils::packageVersion("stars") >= as.package_version("0.6-0")
nrbands_match <- identical(
dim(x)["band"],
dim(stars::read_stars(file, proxy = TRUE))["band"]
)
) && # stars < 0.6-0 has different implementation of band selection in stars_proxy
(stars_ok || is.null(attr(x, "call_list")) || dim(x)["band"] == 1L)
if (nrbands_match) {
return(file)
} else {
message(glue(
"Rewriting the stars object as a temporary file before passing to QGIS, since ",
"the number of bands differs from those in the source file '{ file }'."
"the number of bands { ifelse(stars_ok, 'differs', 'may differ') } ",
"from those in the source file '{ file }'."
))
return(write_stars_as_tempfile_arg(x))
}
Expand Down

0 comments on commit 1dcf18e

Please sign in to comment.