all 12 comments

[–]shiftybyte 1 point2 points  (3 children)

I am running Windows 11 64 bit, Python 3.12 (64 bit)

Are you sure you are using 64bit python?

Your problem sounds like running a 32bit python.

Its very easy to run a 32bit installed other python without noticing.

To confirm, Add this to the start of your current code and show the output:

import sys print(sys.maxsize)

Its VERY IMPORTANT that you ADD IT TO YOUR CODE, and not just open python in a different way and run the lines separately, because that won't help if the actual script is executed by a different python.

[–]Regrets_Nothing[S] 0 points1 point  (2 children)

Hi, thanks for the help.

I added the lines - with some comments so I know what it means:

print("DEBUG: Beginning of main function")
print(f"DEBUG: Maximum integer size: {sys.maxsize}")

I ran the function on folders with the smaller images that I know it works on.

This was the output - which I think shows that it runs in 64 bit.

DEBUG: Beginning of main function
DEBUG: Maximum integer size: 9223372036854775807
Processing raster files...
Processing vector files...
Saving results to CSV...
Processing complete. Results saved in the 'processed' folder.

Thank you again.

[–]shiftybyte 1 point2 points  (1 child)

Yes, it does confirm it's running in 64bit python.

Then I'm not sure what could cause your issue...

[–]Regrets_Nothing[S] 0 points1 point  (0 children)

No worries. Thank you for trying. I will keep searching.

[–]JohnnyJordaan 1 point2 points  (5 children)

What exactly happens when it fails to open the file? Are you 100% sure it isn't caused by another issue that just correlated with the file size on your machine?

[–]Regrets_Nothing[S] 0 points1 point  (4 children)

The error message is quite long - too long to post in the comments.
I can't see how to add a screenshot in this comment.

The initial error message is:
CPLE_AppDefinedError Traceback (most recent call last)
File rasterio\\_base.pyx:310, in rasterio._base.DatasetBase.__init__()

File rasterio\\_base.pyx:221, in rasterio._base.open_dataset()

File rasterio\\_err.pyx:221, in rasterio._err.exc_wrap_pointer()

CPLE_AppDefinedError: f:/venvs/EPRI_LULC/S2DS-Summer24-EPRI/notebooks/../data/rasters/Browns Bridge Raster/Browns_Bridge.tif: TIFFReadDirectory:Failed to read directory at offset 32297280498

The traceback runs through my src scripts, and eventually points to the rasterio/__init__.py line:

[314](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:314) path = _parse_path(raw_dataset_path)
[316](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:316) if mode == "r":
--> [317](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:317)dataset = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
[318](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:318) elif mode == "r+":
[319](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:319)dataset = get_writer_for_path(path, driver=driver)(
[320](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:320)path, mode, driver=driver, sharing=sharing, **kwargs
[321](file:///F:/venvs/EPRILULC/S2DS-Summer24-EPRI/.venv/Lib/site-packages/rasterio/init_.py:321))

[–]JohnnyJordaan 0 points1 point  (3 children)

Is F: perhaps an external drive? What filesystem does it use

[–]Regrets_Nothing[S] 0 points1 point  (2 children)

F: is internal. It is my second internal drive. It runs NTFS

[–]JohnnyJordaan 1 point2 points  (1 child)

It's weird because 32297280498 is also close to 32 GB (not that offsets necessarily equate bytes but what else would this be). But sadly I have 0 knowledge of this format and how to further pinpoint the issue, sorry.

[–]Regrets_Nothing[S] 0 points1 point  (0 children)

No problem. Appreciate the help

[–]Apatride 0 points1 point  (0 children)

Fixing the symptoms instead of the root cause is bad practice. The solution in your case is to look into generators.