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
c16fb530
Commit
c16fb530
authored
Oct 25, 2016
by
Manuel Grizonnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: more gdal libs
parent
dd3ab98b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
14 deletions
+8
-14
python/s2snow/snow_detector.py
python/s2snow/snow_detector.py
+8
-14
No files found.
python/s2snow/snow_detector.py
View file @
c16fb530
...
...
@@ -90,22 +90,16 @@ def burn_polygons_edges(input_img,input_vec):
tmp_line
=
op
.
join
(
input_dir
,
str
(
unique_filename
))
print
"tmpline: "
+
str
(
tmp_line
)
#print "gdal version " + gdal.VersionInfo.str()
gdal
.
VectorTranslate
(
tmp_line
+
".shp"
,
input_vec
,
accessMode
=
'overwrite'
,
geometryType
=
'MULTILINESTRING'
)
if
gdal
.
VersionInfo
()
>=
2000000
:
print
"GDAL version >= 2.0 detected. Where statement syntax have changed in gdal."
# 2) rasterize cloud and cloud shadows polygon borders in green
call_subprocess
([
"gdal_rasterize"
,
"-b"
,
"1"
,
"-b"
,
"2"
,
"-b"
,
"3"
,
"-burn"
,
"0"
,
"-burn"
,
"255"
,
"-burn"
,
"0"
,
"-where"
,
'DN=2'
,
"-l"
,
str
(
unique_filename
),
tmp_line
+
".shp"
,
input_img
])
# 3) rasterize snow polygon borders in magenta
call_subprocess
([
"gdal_rasterize"
,
"-b"
,
"1"
,
"-b"
,
"2"
,
"-b"
,
"3"
,
"-burn"
,
"255"
,
"-burn"
,
"0"
,
"-burn"
,
"255"
,
"-where"
,
'DN=1'
,
"-l"
,
str
(
unique_filename
),
tmp_line
+
".shp"
,
input_img
])
else
:
print
"GDAL version <2."
# 2) rasterize cloud and cloud shadows polygon borders in green
call_subprocess
([
"gdal_rasterize"
,
"-b"
,
"1"
,
"-b"
,
"2"
,
"-b"
,
"3"
,
"-burn"
,
"0"
,
"-burn"
,
"255"
,
"-burn"
,
"0"
,
"-where"
,
"'DN=
\"
2
\"
'"
,
"-l"
,
str
(
unique_filename
),
tmp_line
+
".shp"
,
input_img
])
# 3) rasterize snow polygon borders in magenta
call_subprocess
([
"gdal_rasterize"
,
"-b"
,
"1"
,
"-b"
,
"2"
,
"-b"
,
"3"
,
"-burn"
,
"255"
,
"-burn"
,
"0"
,
"-burn"
,
"255"
,
"-where"
,
"'DN=
\"
1
\"
'"
,
"-l"
,
str
(
unique_filename
),
tmp_line
+
".shp"
,
input_img
])
# 2) rasterize cloud and cloud shadows polygon borders in green
call_subprocess
([
"gdal_rasterize"
,
"-b"
,
"1"
,
"-b"
,
"2"
,
"-b"
,
"3"
,
"-burn"
,
"0"
,
"-burn"
,
"255"
,
"-burn"
,
"0"
,
"-where"
,
'DN=2'
,
"-l"
,
str
(
unique_filename
),
tmp_line
+
".shp"
,
input_img
])
#FIXME can't find the right syntax here to use gdal lib
#gdal.Rasterize(input_img , tmp_line+".shp" , bands = [1,2,3] , burnValues = [0,255,0] , where='DN=2', layers = str(unique_filename) )
# 3) rasterize snow polygon borders in magenta
call_subprocess
([
"gdal_rasterize"
,
"-b"
,
"1"
,
"-b"
,
"2"
,
"-b"
,
"3"
,
"-burn"
,
"255"
,
"-burn"
,
"0"
,
"-burn"
,
"255"
,
"-where"
,
'DN=1'
,
"-l"
,
str
(
unique_filename
),
tmp_line
+
".shp"
,
input_img
])
#FIXME can't find the right syntax here to use gdal lib
#gdal.Rasterize(input_img , tmp_line+".shp" , bands = [1,2,3] , burnValues = [255,0,255] , where='DN=1' , layers = str(unique_filename) )
# 4) remove tmp_line files
for
shp
in
glob
.
glob
(
tmp_line
+
"*"
):
...
...
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