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

January 1st date formatted incorrectly in .tif.aux.json. #1168

Closed
colinbrust opened this issue May 23, 2023 · 2 comments
Closed

January 1st date formatted incorrectly in .tif.aux.json. #1168

colinbrust opened this issue May 23, 2023 · 2 comments

Comments

@colinbrust
Copy link

colinbrust commented May 23, 2023

I recently had to query one of the .json files created with a .tif and noticed that instead of being formatted as {Year}-01-01, Jan 1st is formatted as {Year - 1}-13-01, which lead to issues when parsing the file outside of terra. I did a little digging but was unable to find what might be causing this to happen. Here is an example:

library(terra)
#> terra 1.7.33

r <- terra::rast(nrow=4, ncol=3, nlyrs=3, vals=rep(1:12, 3))
terra::time(r) <- seq.Date(from=as.Date("2022-12-31"), to=as.Date("2023-01-02"), by="days")

terra::writeRaster(r, "./test.tif", overwrite=TRUE)
readLines("./test.tif.aux.json")[2]
#> [1] "\"time\":[\"2022-12-31\",\"2022-13-1\",\"2023-1-2\"],"

Created on 2023-05-23 with reprex v2.0.2

@rhijmans
Copy link
Member

Thank you for reporting this. I now get

[1] "\"time\":[\"2022-12-31\",\"2023-1-1\",\"2023-1-2\"],"

@colinbrust
Copy link
Author

Great! Thank you for looking into this.

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