Skip to content

Commit

Permalink
g
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Dec 24, 2024
1 parent e03ca94 commit 70dc808
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/ncdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ write_tags <- function(tags, nc, varid, prefix="TAG_") {
bsteps <- blocks(rast(x[[1]], nlyr=sum(nlyr(x))), 4)
if (bsteps$n > opt$progress) {
progress <- TRUE
pb <- txtProgressBar(0, bsteps$n)
pb <- utils::txtProgressBar(0, bsteps$n)
pcnt <- 0
} else {
progress <- FALSE
Expand All @@ -199,15 +199,15 @@ write_tags <- function(tags, nc, varid, prefix="TAG_") {
readStart(y)
if (length(ncvars[[i]]$dim) == 3) {
for (j in 1:b$n) {
if (progress) { setTxtProgressBar(pb, pcnt); pcnt <- pcnt + 1 }
if (progress) { utils::setTxtProgressBar(pb, pcnt); pcnt <- pcnt + 1 }
d <- readValues(y, b$row[j], b$nrows[j], 1, nc, FALSE, FALSE)
d[is.nan(d)] <- NA
d <- array(d, c(nc, b$nrows[j], nl[i]))
ncdf4::ncvar_put(ncobj, ncvars[[i]], d, start=c(1, b$row[j], 1), count=c(nc, b$nrows[j], nl[i]))
}
} else {
for (j in 1:b$n) {
if (progress) { setTxtProgressBar(pb, pcnt); pcnt <- pcnt + 1 }
if (progress) { utils::setTxtProgressBar(pb, pcnt); pcnt <- pcnt + 1 }
d <- readValues(y, b$row[j], b$nrows[j], 1, nc, FALSE, FALSE)
d[is.nan(d)] <- NA
d <- matrix(d, ncol=b$nrows[j])
Expand All @@ -220,7 +220,7 @@ write_tags <- function(tags, nc, varid, prefix="TAG_") {
}
write_tags(metags(y), ncobj, ncvars[[i]], "")
}
if (progress) close(pb)
if (progress) utils::close(pb)

ncdf4::ncatt_put(ncobj, 0, "Conventions", "CF-1.4", prec="text")
pkgversion <- drop(read.dcf(file=system.file("DESCRIPTION", package="terra"), fields=c("Version")))
Expand Down

0 comments on commit 70dc808

Please sign in to comment.