Re: NameError: name 'Window' is not defined


Sean Gillies
 

Hi Quin,

The Window class is defined in the rasterio.windows module and you must explicitly import it into your program's code like this:

    from rasterio.windows import Window

Example code in our docs might obscure this need, if you see any docs that don't show import of the Window class, let me know and I'll fix them.

On Mon, May 6, 2019 at 1:23 PM <quinsen.joel@...> wrote:
Hello. I'm new to this forum, so let me know if there are any problems with my question here.

I am trying to use rasterio's windowed reading ability and I am hoping to use the following structure as shown on rasterios documentation page (https://rasterio.readthedocs.io/en/latest/topics/windowed-rw.html):
 
 
```
with rasterio.open('file.tif') as src:
   window = src.read(1, window=Window(0, 0, new_height, new_width)) 
```
 
 
However, when I try to do this I get:
 
```NameError: name 'Window' is not defined```
 
Shouldn't Window() be imported with rasterio? Is this a problem with the version of rasterio I have downloaded or am I missing something really easy here?
 
```
print (rasterio.__version__)
1.0.7
```
 
Thank you for your guidance,
Quin



--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.