Skip to content

Inherit any existing rasterio environment during stack #133

@gjoseph92

Description

@gjoseph92

In #132 I noticed the snippet:

with rasterio.Env(aws_unsigned = True,AWS_S3_ENDPOINT= 's3.af-south-1.amazonaws.com'):
     stack = stackstac.stack(items)

which doesn't currently work the way you'd expect (the environment settings you've just created will be ignored at compute time), but might be a pretty intuitive way to set extra GDAL options without mucking around with LayeredEnvs and the defaults.

We could even deprecate support for passing in a LayeredEnv directly, since it's far more complexity that most users would need, and erring on the side of fewer options is usually better.

There's some complexity around the fact that theoretically different types of Readers are supported, though in practice this is not at all true. Nonetheless, it might be worth extending the Reader protocol to expose either a DEFAULT_ENV: ClassVar[LayeredEnv] or a get_default_env() -> LayeredEnv classmethod.

Then ultimately, within items_to_dask, we'd pull the default env for the specified reader type, and merge it with any currently-set options (via rio.env.getenv()).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions