-
Notifications
You must be signed in to change notification settings - Fork 116
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
handling remote files (or setting rasterio/gdal context) #208
Comments
I've been doing s3 stuff with rasterio and it handles an s3 path without the need for a context mananger, as long as it's a free bucket. rasterstats doesn't change the path at all so it seems to work fine without any adjustment
It can be wrapped in a special rasterio session for a requester pays bucket too. Like with this naip imagery.
rasterstats only reads with the rasterio window method, so as long as the s3 files are cloud optimized geotiffs then it will not download the full raster. |
For anyone looking to do this in a mock S3 tool like minio, I'll save you a google search: rasterio/rasterio#1293 (comment) Just add the following variables to your rasterio.Env: import rasterstats
import rasterio
from shapely.geometry import Polygon
s3_path = 's3://landsat-pds/L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF'
p = Polygon([(465764.5, 2428342.0), (465104.1, 2404237.9), (492840.3, 2402586.9)])
with rasterio.Env(AWS_HTTPS='NO', GDAL_DISABLE_READDIR_ON_OPEN='YES', AWS_VIRTUAL_HOSTING=False, AWS_S3_ENDPOINT='localhost:9000'):
stats = rasterstats.zonal_stats(p, s3_path) |
Hi,
thanks for this great package. I'm wondering if it's possible to pass an open raster (as opposed to simply the path) to zonalstats (without converting to
ndarray
first).My use case is that I'm reading a raster file from a public s3 bucket, which requires the following rasterio context:
which works great by itself. But now I need to calculate zonal stats and I cannot make
rs.zonal_stats
use the rasterio environment. Would it be possible to modify thers.zonal_stats
so that it accepts an openrasterio.DatasetReader
? (or allow passing the context)e.g.
The text was updated successfully, but these errors were encountered: