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

Writing with /vsizip/ strips metadata, doesn't respect overwrite=TRUE #1629

Open
Aariq opened this issue Oct 23, 2024 · 1 comment
Open

Writing with /vsizip/ strips metadata, doesn't respect overwrite=TRUE #1629

Aariq opened this issue Oct 23, 2024 · 1 comment

Comments

@Aariq
Copy link

Aariq commented Oct 23, 2024

Writing to a SOzip by using a /vsizip/ path in writeRaster() only sort of works. The metadata seems to be lost (somewhat defeating the purpose of archiving both the raster and sidecar .aux.json file) and overwrite=TRUE doesn't seem to work. here's a reprex:

library(terra)
#> terra 1.7.78
f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
units(r) <- "m"
dir.create("test/path", recursive = TRUE)
writeRaster(r,
            "/vsizip/{test/path/out}/out",
            filetype = "GTiff",
            gdal = c("STREAMABLE_OUTPUT=YES", "COMPRESS=NONE"))

units(rast("/vsizip/{test/path/out}/out"))
#> [1] ""

writeRaster(r,
            "/vsizip/{test/path/out}/out",
            filetype = "GTiff",
            gdal = c("STREAMABLE_OUTPUT=YES", "COMPRESS=NONE"),
            overwrite = TRUE)
#> Warning: Deleting /vsizip/{test/path/out}/out failed:
#> Undefined error: 0 (GDAL error 1)
#> Warning: out already exists in ZIP file (GDAL error 1)
#> Error: [writeRaster] failed writing GTiff file

Created on 2024-10-23 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14)
#>  os       macOS Sonoma 14.6.1
#>  system   x86_64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Phoenix
#>  date     2024-10-23
#>  pandoc   3.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.0)
#>  codetools     0.2-20  2024-03-31 [2] CRAN (R 4.4.1)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.1   2024-10-10 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.4   2024-04-25 [1] CRAN (R 4.4.0)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#>  knitr         1.48    2024-07-07 [1] CRAN (R 4.4.0)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
#>  Rcpp          1.0.13  2024-07-17 [1] CRAN (R 4.4.0)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.4.0)
#>  rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.0)
#>  rmarkdown     2.28    2024-08-17 [1] CRAN (R 4.4.1)
#>  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
#>  terra       * 1.7-78  2024-05-22 [1] CRAN (R 4.4.0)
#>  withr         3.0.1   2024-07-31 [1] CRAN (R 4.4.0)
#>  xfun          0.48    2024-10-03 [1] CRAN (R 4.4.1)
#>  yaml          2.3.10  2024-07-26 [1] CRAN (R 4.4.0)
#> 
#>  [1] /Users/ericscott/Library/R/x86_64/4.4/library
#>  [2] /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@Aariq
Copy link
Author

Aariq commented Oct 23, 2024

To clarify, it seems the aux.json file both isn't included in the .zip archive and if it was (i.e. the .zip was created with something like zip::zip()), rast("/vsizip/{path/to/zip}/file") doesn't read in the aux.json metadata.

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

1 participant