rasterio
rasterio copied to clipboard
Documentation Example MemoryFile
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())