Skip to content

Commit

Permalink
use reordered dims properly for r-spatial#680
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Apr 24, 2024
1 parent d291c13 commit 71b6ba0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/ncdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ read_ncdf = function(.x, ..., var = NULL, ncsub = NULL, curvilinear = character(

# Create stars dimensions object

if(is.null(nc_dim <- dim(out_data[[1]]))) nc_dim <- dims$length
nc_dim <- dims$count

dimensions <- create_dimensions(setNames(nc_dim, dims$name),
raster)
Expand Down
8 changes: 7 additions & 1 deletion tests/testthat/test-ncdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,15 @@ test_that("axis attribute order -- see #680", {

s2 <- suppressWarnings(stars::read_ncdf(file2))

expect_equal(names(stars::st_dimensions(s2)), c("lon", "lat", "time"))
d <- stars::st_dimensions(s2)

expect_equal(names(d), c("lon", "lat", "time"))

expect_equal(d$time$to, 9)

s3 <- suppressWarnings(stars::read_ncdf(file3))

expect_equal(names(stars::st_dimensions(s3)), c("lon", "lat", "time"))

expect_equal(d$time$to, 9)
})

0 comments on commit 71b6ba0

Please sign in to comment.