Is there any way to open a .tif
image within a .zip
file with rasterio, without having to extract the .tif
from the zip?
I have thousands of images which are nicely grouped in zip files and I want to analyse them with rasterio. Extracting all the images is going to take up quite a bit of storage so if possible I prefer not to...
Thanks!
Yes, rasterio can open datasets contained within .zip
files. Use the zip+file
protocol, and separate the zip path from the path within the zip file with a !
.
Example code:
import rasterio
path = 'zip+file:///path/to/file.zip!/folder/file.tif'
dataset = rasterio.open(path)
There's more information on the Advanced Datasets documentation page.