rasterio icon indicating copy to clipboard operation
rasterio copied to clipboard

Documentation Example MemoryFile

Open apiszcz opened this issue 7 years ago • 0 comments

I reviewed an earlier post from you but was thinking an even simpler example may be of useful

# get sample data set
ds=rio.open(r'testa.tif')
b1=ds.read()
profile=ds.profile

# store dataset to memory
with MemoryFile() as mem:
    with mem.open(**profile) as dst:
        dst.write(b1)

    # write memory to disk
    with open('memfile.tif','wb') as g:
        mem.seek(0)
        g.write(mem.read())

apiszcz avatar May 22 '17 17:05 apiszcz