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

ERROR 4: No such file or directory when attempting to close dataset #1659

Closed
amine-aboufirass opened this issue Mar 22, 2019 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@amine-aboufirass
Copy link

amine-aboufirass commented Mar 22, 2019

Expected behavior and actual behavior.

When I open memory/physical files without using the with statement (namely using dataset.open() and dataset.close(), I believe I should have no warnings or error messages. However I get an error:

ERROR 4: No such file or directory

Steps to reproduce the problem.

import numpy as np
from rasterio.io import MemoryFile
import rasterio

memfile = MemoryFile()
data = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
west_bound = 0; north_bound = 2; cellsize=0.5; nodata = -9999; driver='AAIGrid';
dtype = data.dtype
shape = data.shape
transform = rasterio.transform.from_origin(west_bound, north_bound, cellsize, cellsize)
dataset = memfile.open(driver=driver, width=shape[1], height=shape[0], transform=transform, count=1, dtype=dtype, nodata=nodata)
dataset.write(data,1)
dataset.close()

The line which causes the error is the very last line, namely when we close the dataset.

Operating system

Windows 7 Enterprise, 64 bit

Rasterio version and provenance

rasterio 1.0.21 installed using anaconda

@sgillies sgillies added this to the 1.0.23 milestone Mar 22, 2019
@sgillies sgillies self-assigned this Mar 22, 2019
@sgillies sgillies added the bug label Mar 22, 2019
@sgillies
Copy link
Member

I had some advice for quieting the error on the discussion group, but I see something to be done in the Rasterio code. At https://github.com/mapbox/rasterio/blob/master/rasterio/_io.pyx#L852 we can intercept and discard the error message.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants