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

corrupted NFI_MODIS250m_2011_kNN_Structure_Biomass_TotalLiveAboveGround_v1.tif #417

Open
rygill opened this issue Jan 10, 2025 · 4 comments

Comments

@rygill
Copy link

rygill commented Jan 10, 2025

When running the barebones R script from https://predictiveecology.org/training/_book/ForestsAndFire.html the command

outSim <- do.call(SpaDES.core::simInitAndSpades, out) produces the error:

[rast] cannot open this file as a SpatRaster: Path/SpaDES_book/Wildfire_demo/inputs/NFI_MODIS250m_2011_kNN_Structure_Biomass_TotalLiveAboveGround_v1.tif

and subsequent warning:
Path/SpaDES_book/Wildfire_demo/inputs/NFI_MODIS250m_2011_kNN_Structure_Biomass_TotalLiveAboveGround_v1.tif: TIFFFetchNormalTag:Incorrect count for "SamplesPerPixel" (GDAL error 1)

This file is corrupted on download and cannot be opened in R or QGIS. Downloading this file manually from the source results in a working file.

The script prepInputObjects.R specifies this download (lines 425 and 508).

This error occurs with the 2001 and 2011 datasets.

@achubaty
Copy link
Collaborator

is this a duplicate of #335?

@rygill
Copy link
Author

rygill commented Jan 10, 2025

It is similar, but that issue sounds like it has to do with corruption while unzipping, whereas this is not a zipped file, but a .tif.

If I run line 508 of prepInputObjects.R and paste the subsequent url in a browser, the file downloads without issue.

paste0("http://ftp.maps.canada.ca/pub/nrcan_rncan/Forests_Foret/", "canada-forests-attributes_attributs-forests-canada/2011-attributes_attributs-2011/", "NFI_MODIS250m_2011_kNN_Structure_Biomass_TotalLiveAboveGround_v1.tif")

@achubaty achubaty transferred this issue from PredictiveEcology/LandR Jan 14, 2025
@achubaty
Copy link
Collaborator

can you confirm whether a manual dowload of that file to the destination path, then rerunning the function, is able to load the file successfully? trying to narrow down the issue to the way it's being downloaded, versus the way it's being processed afterward.

@rygill
Copy link
Author

rygill commented Jan 14, 2025

When I manually download the file the file size is smaller than the file the function downloads (302 vs 305 kb). When I use my manually downloaded file in outSim <- do.call(SpaDES.cor::simInitAndSpades, out) I get a warning that (to paraphrase): the file exists and overwrite = FALSE. I'm asked if I want to overwrite the file. If I select no the script exits. If I select yes the manual file is overwritten with the corrupted version.

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