Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeCDF doesn't allow force_v4 #1009

Closed
bocinsky opened this issue Feb 9, 2023 · 1 comment
Closed

writeCDF doesn't allow force_v4 #1009

bocinsky opened this issue Feb 9, 2023 · 1 comment

Comments

@bocinsky
Copy link

bocinsky commented Feb 9, 2023

Hi there,

The terra:::.write_cdf function accepts dots, and checks to see whether force_v4 is included among them, passing it on to ncdf4::nc_create. However, force_v4 is also passed on to ncdf4::ncvar_def, which throws an error. I'm not sure about the appropriate solution, but perhaps force_v4 should be an explicit parameter of the terra::writeCDF (and terra:::.write_cdf) function?

Reprex below. Thanks for all you do!

f <- system.file("ex/elev.tif", package="terra")
r <- terra::rast(f)
fname <- paste0(tempfile(), ".nc")

# Works
rr <- terra::writeCDF(r, fname, overwrite=TRUE, varname="alt",
               longname="elevation in m above sea level", unit="m")

# Error because ncdf4::ncvar_def doesn't accept dots
rr <- terra::writeCDF(r, fname, overwrite=TRUE, varname="alt",
               longname="elevation in m above sea level", unit="m", force_v4 = TRUE)
#> Error in ncdf4::ncvar_def(name = vars[i], units = units[i], dim = list(xdim, : unused argument (force_v4 = TRUE)

Created on 2023-02-09 with reprex v2.0.2

@rhijmans
Copy link
Member

rhijmans commented Feb 9, 2023

Thank you very much. Not sure what I was thinking, but fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants