rspatial / terra

R package for spatial data handling https://rspatial.github.io/terra/reference/terra-package.html
GNU General Public License v3.0
543 stars 90 forks source link

Error in *writeRaster* with overwrite = TRUE, file already exists #1539

Open bryce-carson opened 5 months ago

bryce-carson commented 5 months ago

This script, preaggregator.tar.gz, fails due to one two errors:

  1. (in this issue) "file already exists" despite the argument overwrite = TRUE, or
  2. (in #1538) an "external reference" error.

I am re-running the script, which takes a few minutes, and then I will update this issue and the related issue with further information and explicit quotations of the error messages.

bryce-carson commented 5 months ago

This population.xlsx file is required by the script, and should live in a sibling directory named misc.

bryce-carson commented 5 months ago

The directory structure is as diagrammed below.

[bryce@fedora]~/src/r/spatialEpisim% tree -d -L 1
.
├── gadm
├── misc
├── observeddata
├── preaggregated_data
├── R
├── rsconnect
├── scripts
├── seeddata
├── tif
└── www
bryce-carson commented 5 months ago

I apologize for the series of comments and the slight disorganization of the issue; I can modify the script with the reprex package in mind if needed. The script is quite simple and simply checks for existing files and overwrites them if necessary after aggregating some downloaded TIF format rasters from worldpop.org.

bryce-carson commented 5 months ago

Running the script serially, with %do%, somehow permitted the script to run to completion. I did also enable the cores argument in aggregate.

rhijmans commented 5 months ago

The overwrite error may have been fixed with https://github.com/rspatial/terra/issues/1522. If not, it would be helpful to have a minimal and self-contained example.

bryce-carson commented 5 months ago

The overwrite error may have been fixed with #1522. If not, it would be helpful to have a minimal and self-contained example.

I will try to reproduce the error with the latest development version.