Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoSentinel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoSentinel
Commits
f66bed63
Commit
f66bed63
authored
Mar 19, 2019
by
Mario Chirinos Colunga
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split SCL
parent
8e77c533
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
2 deletions
+79
-2
splitSCL.py
geosentinel/splitSCL.py
+58
-0
L2ASCL_AreaProcessing.sh
tools/L2ASCL_AreaProcessing.sh
+21
-2
No files found.
geosentinel/splitSCL.py
0 → 100755
View file @
f66bed63
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
osgeo.ogr
as
ogr
import
osgeo.osr
as
osr
import
numpy
as
np
import
gdal
import
sys
SCL_COLOR
=
[
(
0
,
0
,
0
,
255
),
#NO_DATA
(
255
,
0
,
0
,
255
),
#SATURATED_OR_DEFECTIVE
(
64
,
64
,
64
,
255
),
#DARK_AREA_PIXELS
(
102
,
51
,
0
,
255
),
#CLOUD_SHADOWS
(
0
,
255
,
0
,
255
),
#VEGETATION
(
255
,
255
,
0
,
255
),
#NOT_VEGETATED
(
0
,
0
,
255
,
255
),
#WATER
(
128
,
128
,
128
,
255
),
#UNCLASSIFIED
(
192
,
192
,
192
,
255
),
#CLOUD_MEDIUM_PROBABILITY
(
255
,
255
,
255
,
255
),
#CLOUD_HIGH_PROBABILITY
(
102
,
204
,
255
,
255
),
#THIN_CIRRUS
(
255
,
153
,
255
,
255
),
#SNOW
]
#-------------------------------------------------------------------------------
def
splitSCL
(
filename
,
outdir
):
inputImage
=
gdal
.
Open
(
filename
)
rows
=
inputImage
.
RasterYSize
cols
=
inputImage
.
RasterXSize
geotransform
=
inputImage
.
GetGeoTransform
()
projection
=
inputImage
.
GetProjection
()
sr
=
osr
.
SpatialReference
()
sr
.
ImportFromWkt
(
projection
)
driverTiff
=
gdal
.
GetDriverByName
(
'GTiff'
)
for
c
in
range
(
len
(
SCL_COLOR
)):
outputfile
=
outdir
+
filename
[:
-
4
]
+
"_"
+
str
(
c
)
+
".tif"
output
=
driverTiff
.
Create
(
outputfile
,
cols
,
rows
,
4
,
gdal
.
GDT_Byte
)
classMask
=
inputImage
.
GetRasterBand
(
1
)
.
ReadAsArray
(
0
,
0
,
cols
,
rows
)
==
c
for
b
in
range
(
1
,
output
.
RasterCount
+
1
):
output
.
GetRasterBand
(
b
)
.
SetNoDataValue
(
0
)
output
.
GetRasterBand
(
b
)
.
WriteArray
(
classMask
*
SCL_COLOR
[
c
][
b
-
1
])
output
.
GetRasterBand
(
b
)
.
FlushCache
()
output
.
SetGeoTransform
(
geotransform
)
output
.
SetProjection
(
projection
)
output
=
None
inputImage
=
None
#-------------------------------------------------------------------------------
def
main
(
argv
):
splitSCL
(
argv
[
1
],
argv
[
2
])
if
__name__
==
"__main__"
:
main
(
sys
.
argv
)
tools/L2ASCL_AreaProcessing.sh
View file @
f66bed63
...
@@ -230,7 +230,26 @@ else
...
@@ -230,7 +230,26 @@ else
mergeL2ASCL_JSON.py
$USERDIR
"out/mask/SCL/json/"
>
$USERDIR
"scl_data.json"
mergeL2ASCL_JSON.py
$USERDIR
"out/mask/SCL/json/"
>
$USERDIR
"scl_data.json"
fi
fi
#8.-Create Tiles
#8.- Split SCL
echo
${
RED
}
"Spliting SCL image..."
${
NC
}
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
else
echo
"BY DATE"
cd
$USERDIR
"out/mask/SCL/"
if
[
!
-d
"split"
]
;
then
mkdir split
fi
for
f
in
$(
ls
*
.tif
)
;
do
echo
$f
splitSCL.py
$f
split
/
done
fi
#9.-Create Tiles
echo
${
RED
}
"Creating Tiles..."
${
NC
}
echo
${
RED
}
"Creating Tiles..."
${
NC
}
if
[
$BYTILE
-ne
"0"
]
;
then
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
echo
"BY TILE"
...
@@ -276,7 +295,7 @@ else
...
@@ -276,7 +295,7 @@ else
cd
..
cd
..
done
done
cd
$USERDIR
"out/mask/SCL/"
cd
$USERDIR
"out/mask/SCL/
split/
"
if
[
!
-d
"tiles"
]
;
then
if
[
!
-d
"tiles"
]
;
then
mkdir
tiles
mkdir
tiles
fi
fi
...
...
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