Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Remote Modules
let-it-snow
Commits
234b238d
Commit
234b238d
authored
Jul 26, 2016
by
Manuel Grizonnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: take multiplicator into account to create RGB color composition
parent
93cf8f39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
python/s2snow/snow_detector.py
python/s2snow/snow_detector.py
+18
-5
No files found.
python/s2snow/snow_detector.py
View file @
234b238d
...
...
@@ -59,7 +59,7 @@ def polygonize(input_img,input_mask,output_vec):
"""Helper function to polygonize raster mask using gdal polygonize"""
call_subprocess
([
"gdal_polygonize.py"
,
input_img
,
"-f"
,
"ESRI Shapefile"
,
"-mask"
,
input_mask
,
output_vec
])
def
composition_RGB
(
input_img
,
output_img
):
def
composition_RGB
(
input_img
,
output_img
,
nSWIR
,
nRed
,
nGreen
,
multi
):
"""Make a RGB composition to highlight the snow cover
input_img: multispectral tiff, output_img: false color
...
...
@@ -67,9 +67,22 @@ def composition_RGB(input_img,output_img):
SWIR in in put images.
"""
#call_subprocess(["gdal_translate","-co","PHOTOMETRIC=RGB","-scale","0","300","-ot","Byte","-b",str(nSWIR),"-b",str(nRed),"-b",str(nGreen),input_img,output_img])
call_subprocess
([
"otbcli_Convert"
,
"-in"
,
input_img
,
"-out"
,
output_img
,
"uint8"
,
"-type"
,
"linear"
])
scale_factor
=
300
*
multi
call_subprocess
([
"gdal_translate"
,
"-co"
,
"PHOTOMETRIC=RGB"
,
"-scale"
,
"0"
,
str
(
scale_factor
),
"-ot"
,
"Byte"
,
"-b"
,
str
(
nSWIR
),
"-b"
,
str
(
nRed
),
"-b"
,
str
(
nGreen
),
input_img
,
output_img
])
#Comment this part which use an alternative solution with OTB Convert application
# #create temporary file to add nodata value
# f = tempfile.NamedTemporaryFile(suffix='.tif')
# #Store nodata in a temporary file
# call_subprocess(["otbcli_ManageNoData", "-in", input_img, "-out", f.name, "int16", "-mode", "changevalue", "-mode.changevalue.newv", str(nodata)])
# #Convert image to RGB
# call_subprocess(["otbcli_Convert", "-in", f.name, "-out", output_img, "uint8", "-type", "linear"])
# f.close()
def
burn_polygons_edges
(
input_img
,
input_vec
):
"""Burn polygon borders onto an image with the following symbology:
...
...
@@ -284,7 +297,7 @@ class snow_detector :
polygonize
(
op
.
join
(
self
.
path_tmp
,
"final_mask.tif"
),
op
.
join
(
self
.
path_tmp
,
"final_mask.tif"
),
op
.
join
(
self
.
path_tmp
,
"final_mask_vec.shp"
))
#RGB composition
composition_RGB
(
self
.
img
,
op
.
join
(
self
.
path_tmp
,
"composition.tif"
))
composition_RGB
(
self
.
img
,
op
.
join
(
self
.
path_tmp
,
"composition.tif"
)
,
self
.
nSWIR
,
self
.
nRed
,
self
.
nGreen
,
self
.
multi
)
#Burn polygons edges on the composition
#TODO add pass1 snow polygon in yellow
...
...
@@ -407,7 +420,7 @@ class snow_detector :
#Index of bands in R1 and R2 respectively
nGreen
=
2
nSWIR
=
5
nRed
=
3
nRed
=
3
nodata
=-
10000
if
not
os
.
path
.
isdir
(
self
.
img
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment