Finish pipeline for True-Colo products!

This commit is contained in:
heyarne 2021-02-16 12:58:16 +00:00
commit 72efc4d8e4
8 changed files with 3669 additions and 8532 deletions

2
.gitignore vendored
View file

@ -8,7 +8,7 @@
*.tif.aux.xml *.tif.aux.xml
*.tiff.aux.xml *.tiff.aux.xml
*.zip *.zip
*.SAFE/* **/*.SAFE/*
.jupyter .jupyter
.local .local

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -469,7 +469,14 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"We want to take the product that has the biggest intersection area with our region of interest:" "Because downloads are large, we skip unnecessary downloads wherever possible.\n",
"\n",
"- For this particular example we can select exactly one\n",
"- \n",
"\n",
"\n",
"- Select biggest intersection area\n",
"- Figure out which tiles are needed \n"
] ]
}, },
{ {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -111,9 +111,14 @@ def scihub_bgr_paths(raster_path, resolution=None):
def scihub_normalize_range(v): def scihub_normalize_range(v):
'''
Raster files downloaded from the Copernicus Open Access Hub can contain
pixels with reflectance values outside of the allowed range. This function
discards those values and normalizes the range of the returned raster file
to be [0...1].
'''
return np.clip(v, 0, 2000) / 2000 return np.clip(v, 0, 2000) / 2000
def reproject_raster_image(src, dst, target_crs): def reproject_raster_image(src, dst, target_crs):
''' '''
@ -138,4 +143,29 @@ def reproject_raster_image(src, dst, target_crs):
src_crs=src.crs, src_crs=src.crs,
dst_transform=transform, dst_transform=transform,
dst_crs=target_crs, dst_crs=target_crs,
resampling=Resampling.nearest) resampling=Resampling.nearest)
# TODO: This is documented somewhere in the python docs, we should link to it here
class RasterReaderList():
'''
This class allows opening a list of file paths in a `with` block using
rasterio.open. They get automatically closed when the context created by
the `with` block is left.
'''
def __init__(self, paths):
self.open_files = []
self.paths = paths
def __enter__(self):
for f in self.paths:
self.open_files.append(r.open(f))
return self.open_files
def __exit__(self, _type, _value, _traceback):
for f in self.open_files:
f.close()