Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Sen2Chain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESPACE-DEV
Sen2Chain
Commits
ba9c3259
Commit
ba9c3259
authored
6 years ago
by
Jeremy Commins
Browse files
Options
Downloads
Patches
Plain Diff
Code style and comments: create_cloud_mask_v2
parent
138fcdc9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sen2chain/cloud_mask.py
+16
-12
16 additions, 12 deletions
sen2chain/cloud_mask.py
with
16 additions
and
12 deletions
sen2chain/cloud_mask.py
+
16
−
12
View file @
ba9c3259
...
@@ -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)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment