Skip to content
Snippets Groups Projects
Commit ba9c3259 authored by Jeremy Commins's avatar Jeremy Commins
Browse files

Code style and comments: create_cloud_mask_v2

parent 138fcdc9
No related branches found
No related tags found
No related merge requests found
...@@ -14,11 +14,12 @@ from shapely.ops import transform ...@@ -14,11 +14,12 @@ from shapely.ops import transform
import rasterio import rasterio
from rasterio.features import shapes, rasterize from rasterio.features import shapes, rasterize
import numpy as np import numpy as np
from typing import Mapping, Sequence, AbstractSet, List, Set, Dict, Tuple, Optional, Union import gdal
import otbApplication import otbApplication
# type annotations
from typing import Mapping, Sequence, AbstractSet, List, Set, Dict, Tuple, Optional, Union
from .config import Config from .config import Config
import gdal
import os
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
...@@ -253,13 +254,16 @@ def create_cloud_mask_v2(cloud_mask: Union[str, pathlib.PosixPath], out_path="./ ...@@ -253,13 +254,16 @@ def create_cloud_mask_v2(cloud_mask: Union[str, pathlib.PosixPath], out_path="./
LOGGER.info("Creating cloud-mask_v2") LOGGER.info("Creating cloud-mask_v2")
out_temp_path = Path(Config().get("temp_path")) out_temp_path = Path(Config().get("temp_path"))
# LOGGER.info(out_temp_path) # LOGGER.info(out_temp_path)
# LOGGER.info(str(out_temp_path)) # LOGGER.info(str(out_temp_path))
out_bin = str(out_temp_path) + '/temp_bin.tif' # ATTENTION, si jamais des traitements en parallèle: les fichiers
out_erode = str(out_temp_path) + '/temp_erode.tif' # temporaires auront le même nom => conflits
out_dilate = str(out_temp_path) + '/temp_dilate.tif' # à utiliser uniquement pour des tests
out_bin = str(out_temp_path / "temp_bin.tif")
# Seuillage du masque nuage SEN2COR out_erode = str(out_temp_path / "temp_erode.tif")
out_dilate = str(out_temp_path / "temp_dilate.tif")
# Seuillage du masque nuage Sen2Cor
CLD_seuil = 25 CLD_seuil = 25
BandMath = otbApplication.Registry.CreateApplication("BandMath") BandMath = otbApplication.Registry.CreateApplication("BandMath")
BandMath.SetParameterStringList("il", [str(cloud_mask)]) BandMath.SetParameterStringList("il", [str(cloud_mask)])
...@@ -299,11 +303,11 @@ def create_cloud_mask_v2(cloud_mask: Union[str, pathlib.PosixPath], out_path="./ ...@@ -299,11 +303,11 @@ def create_cloud_mask_v2(cloud_mask: Union[str, pathlib.PosixPath], out_path="./
# Enregistrement JP2000 # Enregistrement JP2000
src_ds = gdal.Open(out_dilate) src_ds = gdal.Open(out_dilate)
driver = gdal.GetDriverByName("JP2OpenJPEG") driver = gdal.GetDriverByName("JP2OpenJPEG")
dst_ds = driver.CreateCopy(str(out_path), src_ds, options=['CODEC=JP2', 'QUALITY=100', 'REVERSIBLE=YES', 'YCBCR420=NO']) dst_ds = driver.CreateCopy(str(out_path), src_ds, options=["CODEC=JP2", "QUALITY=100", "REVERSIBLE=YES", "YCBCR420=NO"])
dst_ds = None dst_ds = None
src_ds = None src_ds = None
#os.remove(out_bin) #os.remove(out_bin)
#os.remove(out_erode) #os.remove(out_erode)
#os.remove(out_dilate) #os.remove(out_dilate)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment