dlr-eoc / ukis-pysat

The ukis-pysat package provides generic classes and functions to query, access and process multi-spectral and SAR satellite images
Apache License 2.0
27 stars 8 forks source link

Dangling rasterio.dataset #45

Closed fwfichtner closed 4 years ago

fwfichtner commented 4 years ago

We don't enforce closing of the dataset, and we're not even very clear about that you should do this in the documentation (even though we offer the possibility), nor do we close img when we're testing.

We could offer using ukis-pysat as context manager or at least document this better and use it ourselves.

fwfichtner commented 4 years ago

To clearify, we're opening the dataset, but don't enforce closing (but have the option). Another alternative would be using a context manager like we do with the data class.

    class Image:
        def __init__(self
             self.dataset = rasterio.open(path)

        ...

        def close(self):
            """closes Image"""
            self.dataset.close()
fwfichtner commented 4 years ago

With #47 this is at least much better for the tests.

fwfichtner commented 4 years ago

Let's really make it possible to wrap it all up in a context manager.

MWieland commented 4 years ago

Agree with that.