Remove extra folders and rename source folder
|
|
@ -1,36 +0,0 @@
|
|||
import zipfile
|
||||
|
||||
|
||||
def band_paths(p, bands, resolution=None):
|
||||
|
||||
'''
|
||||
|
||||
Given a zip file at `p`, returns the paths inside p to the raster files containing
|
||||
|
||||
information for the given bands. Because some bands are available in more than one
|
||||
|
||||
resolution, this can be filtered by prodiding a third parameter (e.g. resolution='10m').
|
||||
|
||||
|
||||
|
||||
The returned paths are formatted in the zip scheme as per Apache Commons VFS and can
|
||||
|
||||
thus be directly opened by rasterio.
|
||||
|
||||
'''
|
||||
|
||||
with zipfile.ZipFile(p) as f:
|
||||
|
||||
files = f.namelist()
|
||||
|
||||
rasters = [f for f in files if f.endswith('.jp2')]
|
||||
rasters = [r for r in rasters for b in bands if b in r]
|
||||
if resolution:
|
||||
rasters = [r for r in rasters if resolution in r]
|
||||
|
||||
rasters = ['zip+file://' + p + '!/' + r for r in rasters]
|
||||
return rasters
|
||||
|
||||
|
||||
def rgb_paths(zip_file, resolution='10m'):
|
||||
return band_paths(zip_file, ['B02', 'B03', 'B04'], resolution)
|
||||
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |