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

'DatasetReader' object has no attribute 'gw' #72

Closed
mmann1123 opened this issue May 10, 2021 · 3 comments
Closed

'DatasetReader' object has no attribute 'gw' #72

mmann1123 opened this issue May 10, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@mmann1123
Copy link
Collaborator

I have run into this a few times now since the latest update. I haven't had time to look into it. Sorry with Fiona pulling at me all the time, I have about 1 hr of productive work time a day :(

You probably already have it resolved but thought I would check

import geowombat as gw
from geowombat.data import rgbn

from rasterio.windows import Window
w = Window(row_off=0, col_off=0, height=100, width=100)

with gw.open(rgbn,
                band_names=['blue', 'green', 'red'],
                num_workers=8,
                indexes=[1, 2, 3],
                window=w,
                ) as src:
    print(src)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/Documents/github/pyGIS/pygis/docs/test.py in 
      1185                 num_workers=8,
     1186                 indexes=[1, 2, 3],
---> 1187                 window=w,
     1188                 ) as src:
     1189     print(src)

~/anaconda3/envs/pygisbookgw/lib/python3.7/site-packages/geowombat/core/api.py in __init__(self, filename, band_names, time_names, stack_dim, bounds, bounds_by, resampling, persist_filenames, netcdf_vars, mosaic, overlap, nodata, dtype, num_workers, **kwargs)
    412                              chunks=chunks,
    413                              num_workers=num_workers,
--> 414                              **kwargs)
    415 
    416             self.__filenames = [filename]

~/anaconda3/envs/pygisbookgw/lib/python3.7/site-packages/geowombat/core/api.py in read(filename, band_names, time_names, bounds, chunks, num_workers, **kwargs)
    174                 kwargs['window'] = from_bounds(*bounds, transform=src.gw.transform)
    175 
--> 176             ycoords, xcoords, attrs = get_attrs(src, **kwargs)
    177 
    178         data = dask.compute(read_delayed(filename,

~/anaconda3/envs/pygisbookgw/lib/python3.7/site-packages/geowombat/core/api.py in get_attrs(src, **kwargs)
     71     attrs = dict()
     72 
---> 73     attrs['transform'] = src.gw.transform
     74 
     75     if hasattr(src, 'crs'):

AttributeError: 'DatasetReader' object has no attribute 'gw'
@mmann1123 mmann1123 added the bug Something isn't working label May 10, 2021
@jgrss
Copy link
Owner

jgrss commented May 11, 2021

I hadn't seen this so thanks for finding. It should be fixed in 1156e2f.

@mmann1123
Copy link
Collaborator Author

Same issue, new place

bounds = (793475.76, 2049033.03, 794222.03, 2049527.24)

with gw.open(rgbn,
                band_names=['green', 'red', 'nir'],
                num_workers=8,
                indexes=[2, 3, 4],
                bounds=bounds,
                out_dtype='float32') as src:
    print(src)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/Documents/github/pyGIS/pygis/docs/test.py in 
      1196                 indexes=[2, 3, 4],
      1197                 bounds=bounds,
----> 1198                 out_dtype='float32') as src:
      1199     print(src)
     1200 

~/anaconda3/envs/pygisbookgw/lib/python3.7/site-packages/geowombat/core/api.py in __init__(self, filename, band_names, time_names, stack_dim, bounds, bounds_by, resampling, persist_filenames, mosaic, overlap, nodata, dtype, num_workers, **kwargs)
    402                              chunks=chunks,
    403                              num_workers=num_workers,
--> 404                              **kwargs)
    405 
    406             self.__filenames = [filename]

~/anaconda3/envs/pygisbookgw/lib/python3.7/site-packages/geowombat/core/api.py in read(filename, band_names, time_names, bounds, chunks, num_workers, **kwargs)
    172 
    173             if bounds and ('window' not in kwargs):
--> 174                 kwargs['window'] = from_bounds(*bounds, transform=src.gw.transform)
    175 
    176             ycoords, xcoords, attrs = get_attrs(src, **kwargs)

AttributeError: 'DatasetReader' object has no attribute 'gw'

@jgrss
Copy link
Owner

jgrss commented May 11, 2021

Added a fix in 5d79796.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants