Re: MemoryFile workflow - should closing a dataset close the memfile?


You could use a context manager to clean it up automatically:

from contextlib import contextmanager
import rasterio
from rasterio import MemoryFile
def mem_raster(data, **profile):
    with MemoryFile() as memfile:
        with**profile) as dataset_writer:
        with as dataset_reader:
            yield dataset_reader
#setup, get data from somewhere, copy or create profile etc...
with mem_raster(data, **profile) as ds:
# the memfile is cleaned up after exiting the with context

Join to automatically receive all group messages.