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
AttributeError when running zonal_stats #173
Comments
Apologies, I was using reading the raster to memory before calling zonal_stats. Simply supplying the file path to zonal_stats fixed the issue. |
I'd request this issue is re-opened. An in-memory raster should be an accepted input. Being required to write it to disk and manage temporary files is a needlessly burdensome workaround. |
I would second request to re-open - I'm encountering the exact same issue with trying to use in-memory raster as opposed to passing the file path to zonal_stats. |
In-memory rasters (more specifically a numpy array) can be passed as the raster data source but you need to also specify affine transform to tie it to geographic coordinates. See https://pythonhosted.org/rasterstats/manual.html#raster-data-sources |
I see this issue is closed, but I've been stuck on specifying the affine instance most of the afternoon without any success. I've tried to baby-step my way through:
What am I missing? |
@janderson5417 please see the link above for a usage example. You need to use |
@perrygeo thank you! You can likely discern I'm learning (!) so really appreciate your help. I was traveling yesterday and couldn't try it out until today...if I can stretch your patience a bit, I tried the following based on your input:
It returned an empty list, although I can confirm data in QGIS for both the vector + raster data. Maybe I implemented your response incorrectly? |
@perrygeo --just for clarification, AttributeError: 'DatasetReader' object has no attribute 'affine' |
@perrygeo --apologies, I've downloaded the repo files and am walking through your notes (which are fantastic)--thank you!!! |
I'm trying to run zonal_stats and I'm getting the following error in the _init_ function of io.py (line 242):
AttributeError: 'GeneratorContextManager' object has no attribute 'transform'
I've recreated the error with a variety of raster and vector data on a fresh virtual environment with rasterstats version 0.13.0. I've experimented with using different combinations of rasterstats/rasterio versions but I'm still seeing the issue. Any insight would be greatly appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: