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
de258520
Commit
de258520
authored
Mar 13, 2019
by
Mario Chirinos Colunga
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mario image merge
parent
6d996f1f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
195 additions
and
48 deletions
+195
-48
APISentinel.py
geosentinel/APISentinel.py
+1
-0
findProducts.py
geosentinel/findProducts.py
+5
-6
polygonToBox.pyc
geosentinel/polygonToBox.pyc
+0
-0
L2AProductListExtractData.sh
tools/L2AProductListExtractData.sh
+2
-2
L2ASCL_AreaProcessing.sh
tools/L2ASCL_AreaProcessing.sh
+182
-37
mergeImages.sh
tools/mergeImages.sh
+3
-3
mergeImagesByDirectory.sh
tools/mergeImagesByDirectory.sh
+2
-0
No files found.
geosentinel/APISentinel.py
View file @
de258520
...
@@ -94,6 +94,7 @@ class APISentinel(object):
...
@@ -94,6 +94,7 @@ class APISentinel(object):
os
.
chdir
(
dir
)
os
.
chdir
(
dir
)
# self.api.download_all(products)
# self.api.download_all(products)
for
p
in
products
:
for
p
in
products
:
print
(
products
[
p
][
'filename'
])
self
.
api
.
download
(
p
)
self
.
api
.
download
(
p
)
def
filterProducts
(
self
,
productList
):
def
filterProducts
(
self
,
productList
):
...
...
geosentinel/findProducts.py
View file @
de258520
...
@@ -54,15 +54,14 @@ def main(argv):
...
@@ -54,15 +54,14 @@ def main(argv):
print
(
str
(
len
(
matchingProducts
))
+
" of "
+
str
(
len
(
fileNames
))
+
" products found."
)
print
(
str
(
len
(
matchingProducts
))
+
" of "
+
str
(
len
(
fileNames
))
+
" products found."
)
rawDir
=
inDir
.
replace
(
cfg
[
'productLevel'
],
productsCodes
[
cfg
[
'productLevel'
]])
rawDir
=
inDir
.
replace
(
cfg
[
'productLevel'
],
productsCodes
[
cfg
[
'productLevel'
]])
print
(
rawDir
)
print
(
rawDir
)
text
=
""
text
=
""
while
text
!=
"yes"
and
text
!=
"no"
:
while
text
!=
"yes"
and
text
!=
"no"
:
text
=
raw_input
(
"Do you want to download this products to "
+
rawDir
+
" ? (yes, no)"
)
text
=
raw_input
(
"Do you want to download this products to "
+
rawDir
+
" ? (yes, no)"
)
if
text
==
"yes"
:
if
text
==
"yes"
:
sentinel
.
downloadProducts
(
productList
,
rawDir
)
# sentinel.downloadProducts(productList,rawDir)
print
(
"L1CProductListToL2A.sh "
+
rawDir
+
" "
+
inDir
+
" 1"
)
print
(
"L1CProductListToL2A.sh "
+
rawDir
+
" "
+
inDir
+
" 1"
)
os
.
system
(
"L1CProductListToL2A.sh "
+
rawDir
+
" "
+
inDir
+
" 1"
)
# os.system("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
text
=
""
text
=
""
while
text
!=
"yes"
and
text
!=
"no"
:
while
text
!=
"yes"
and
text
!=
"no"
:
text
=
raw_input
(
"Do you want to link this products to "
+
outdir
+
" ? (yes, no)"
)
text
=
raw_input
(
"Do you want to link this products to "
+
outdir
+
" ? (yes, no)"
)
...
...
geosentinel/polygonToBox.pyc
View file @
de258520
No preview for this file type
tools/L2AProductListExtractData.sh
View file @
de258520
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
PRODCUTSDIR
=
$1
#Products Intput directory
PRODCUTSDIR
=
$1
#Products Intput directory
JP2DIR
=
$2
#JP2 Output Directory
JP2DIR
=
$2
#JP2 Output Directory
JOBS
=
${
3
:-
1
}
JOBS
=
${
3
:-
1
}
BYTILE
=
${
4
:-
0
}
cd
$PRODCUTSDIR
cd
$PRODCUTSDIR
ls
*
.zip | parallel
--jobs
$JOBS
ExtractData.sh
{}
$JP2DIR
1
ls
*
.zip | parallel
--jobs
$JOBS
ExtractData.sh
{}
$JP2DIR
$BYTILE
...
...
tools/L2ASCL_AreaProcessing.sh
View file @
de258520
...
@@ -8,7 +8,7 @@ BYTILE=${2:-0}
...
@@ -8,7 +8,7 @@ BYTILE=${2:-0}
# exit
# exit
#fi
#fi
echo
"
Iniciando proceso
..."
echo
"
Starting Process
..."
echo
$USERDIR
"findProducts.json"
echo
$USERDIR
"findProducts.json"
wkt
=
$(
getJSONparameter.py
$USERDIR
"findProducts.json"
wkt
)
wkt
=
$(
getJSONparameter.py
$USERDIR
"findProducts.json"
wkt
)
RED
=
'\033[0;31m'
RED
=
'\033[0;31m'
...
@@ -19,6 +19,12 @@ echo $wkt
...
@@ -19,6 +19,12 @@ echo $wkt
echo
$USERDIR
echo
$USERDIR
cd
$USERDIR
cd
$USERDIR
#0.- Create Shape File From WKT
echo
"
${
RED
}
Creating Shape file...
${
NC
}
"
rm
-r
myshape
wktToShape.py
"
$wkt
"
"myshape"
#1.- Link L2A products
#1.- Link L2A products
echo
"Linking Products..."
echo
"Linking Products..."
if
[
!
-d
"L2A"
]
;
then
if
[
!
-d
"L2A"
]
;
then
...
@@ -27,7 +33,7 @@ fi
...
@@ -27,7 +33,7 @@ fi
cd
L2A
cd
L2A
rm
*
rm
*
cd
..
cd
..
echo
yes
| findProducts.py
$USERDIR
"findProducts.json"
yes
yes
| findProducts.py
$USERDIR
"findProducts.json"
#2.- Extract Images
#2.- Extract Images
...
@@ -35,11 +41,18 @@ echo "Extracting JP2 Images..."
...
@@ -35,11 +41,18 @@ echo "Extracting JP2 Images..."
if
[
!
-d
"jp2"
]
;
then
if
[
!
-d
"jp2"
]
;
then
mkdir
jp2
mkdir
jp2
fi
fi
L2AProductListExtractData.sh
$USERDIR
"L2A/"
$USERDIR
"jp2/"
4
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
L2AProductListExtractData.sh
$USERDIR
"L2A/"
$USERDIR
"jp2/"
4 1
else
echo
"BY DATE"
L2AProductListExtractData.sh
$USERDIR
"L2A/"
$USERDIR
"jp2/"
4 0
fi
#3.- Merge Images
#3.- Merge Images
echo
"
*************************************************
Merging Images..."
echo
"
\n
Merging Images..."
if
[
$BYTILE
-ne
"0"
]
;
then
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
echo
"BY TILE"
cd
$USERDIR
"jp2/"
cd
$USERDIR
"jp2/"
...
@@ -51,22 +64,65 @@ if [ $BYTILE -ne "0" ]; then
...
@@ -51,22 +64,65 @@ if [ $BYTILE -ne "0" ]; then
if
[
!
-d
"../out/"
$i
]
;
then
if
[
!
-d
"../out/"
$i
]
;
then
mkdir
"../out/"
$i
mkdir
"../out/"
$i
fi
fi
"mergeImagesByDirectory.sh"
$USERDIR
"jp2/"
$i
../../../out/
$i
"
$wkt
"
mergeImagesByDirectory.sh
$USERDIR
"jp2/"
$i
../../../out/
$i
"
$wkt
"
done
done
else
else
echo
"BY DATE"
echo
"BY DATE"
# mergeImagesByDirectory.sh $USERDIR"jp2/" "$wtk" 4
cd
$USERDIR
"jp2/"
if
[
!
-d
"../out"
]
;
then
mkdir
"../out"
fi
mergeImagesByDirectory.sh
$USERDIR
"jp2/"
$USERDIR
/out/
"
$wkt
"
4
fi
fi
#4.- Mask raster with shape file
echo
"
\n
Applying Mask..."
#4.- Delete images with few data
echo
"****************************************************** Deleting Images..."
if
[
$BYTILE
-ne
"0"
]
;
then
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
echo
"BY TILE"
cd
$USERDIR
"jp2/"
cd
$USERDIR
"out/"
for
d
in
$(
ls
-d
*
/
)
;
do
cd
$d
if
[
!
-d
"mask"
]
;
then
mkdir
mask
fi
for
i
in
$(
ls
*
.tif
)
;
do
if
[
!
-e
mask/
$i
]
;
then
gdalwarp
-cutline
$USERDIR
"myshape/wkt.shp"
-crop_to_cutline
-dstalpha
$i
mask/
$i
else
echo
"Passing "
$i
fi
done
cd
..
done
else
echo
"BY DATE"
cd
$USERDIR
"out/"
if
[
!
-d
"mask"
]
;
then
mkdir
mask
fi
for
i
in
$(
ls
*
.tif
)
;
do
if
[
!
-e
mask/
$i
]
;
then
gdalwarp
-cutline
../myshape/wkt.shp
-crop_to_cutline
-dstalpha
$i
mask/
$i
else
echo
"Passing "
$i
fi
done
fi
#5.- Delete images with few data
echo
"
\n
Deleting Images..."
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
cd
$USERDIR
"out/"
for
i
in
$(
ls
-d
*
/
)
;
do
for
i
in
$(
ls
-d
*
/
)
;
do
cd
../out/
$i
cd
$i
"mask"
echo
$i
echo
$i
if
[
!
-d
"SCL"
]
;
then
if
[
!
-d
"SCL"
]
;
then
mkdir
SCL
mkdir
SCL
...
@@ -82,17 +138,12 @@ if [ $BYTILE -ne "0" ]; then
...
@@ -82,17 +138,12 @@ if [ $BYTILE -ne "0" ]; then
fileprefix
=
$(
echo
$scl
|
(
cut
-d
"_"
-f1
)
)
fileprefix
=
$(
echo
$scl
|
(
cut
-d
"_"
-f1
)
)
cp
../
$fileprefix
"_TCI_60m.tif"
../TCI/
$fileprefix
"_TCI_60m.tif"
cp
../
$fileprefix
"_TCI_60m.tif"
../TCI/
$fileprefix
"_TCI_60m.tif"
done
done
cd
../TCI
cd
$USERDIR
"out/"
mogrify
-format
jpg
-quality
100
*
.tif
mkdir
thumbnails
mogrify
-path
./thumbnails
-resize
10%
*
.jpg
cd
$USERDIR
"jp2/"
done
done
else
else
echo
"BY DATE"
echo
"BY DATE"
cd
jp2/merge_out/
cd
$USERDIR
"out/mask/"
if
[
!
-d
"SCL"
]
;
then
if
[
!
-d
"SCL"
]
;
then
mkdir
SCL
mkdir
SCL
fi
fi
...
@@ -106,51 +157,145 @@ else
...
@@ -106,51 +157,145 @@ else
for
scl
in
$(
ls
*
.tif
)
for
scl
in
$(
ls
*
.tif
)
do
do
fileprefix
=
$(
echo
$scl
|
(
cut
-d
"_"
-f1
)
)
fileprefix
=
$(
echo
$scl
|
(
cut
-d
"_"
-f1
)
)
cp
../
$fileprefix
"_TCI_10m.tif"
../TCI/
$fileprefix
"_TCI_10m.tif"
cp
../
$fileprefix
"_TCI_60m.tif"
../TCI/
$fileprefix
"_TCI_60m.tif"
cd
../TCI
done
done
cd
../TCI
echo
"mogrify -format jpg -quality 100 *.tif"
mogrify
-format
jpg
-quality
100
*
.tif
mkdir
thumbnails
mogrify
-path
./thumbnails
-resize
10%
*
.jpg
fi
fi
#5.-Extract SCL information
#6.-Creating Thumbnails
echo
"**************************************************** Extracting SCL information..."
echo
"Creating Thumbnails"
cd
$USERDIR
"jp2/"
if
[
$BYTILE
-ne
"0"
]
;
then
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
echo
"BY TILE"
cd
$USERDIR
"out/"
for
i
in
$(
ls
-d
*
/
)
;
do
cd
$i
"mask"
if
[
!
-d
"SCL/thumbnails"
]
;
then
mkdir
SCL/thumbnails
fi
if
[
!
-d
"TCI/thumbnails"
]
;
then
mkdir
TCI/thumbnails
fi
cd
TCI
mogrify
-format
jpg
-quality
100
*
.tif
mogrify
-path
./thumbnails
-resize
10%
*
.jpg
cd
$USERDIR
"out/"
done
else
echo
"BY DATE"
cd
$USERDIR
"out/mask/"
if
[
!
-d
"SCL/thumbnails"
]
;
then
mkdir
SCL/thumbnails
fi
if
[
!
-d
"TCI/thumbnails"
]
;
then
mkdir
TCI/thumbnails
fi
cd
TCI
mogrify
-format
jpg
-quality
100
*
.tif
mogrify
-path
./thumbnails
-resize
10%
*
.jpg
fi
#7.-Extract SCL information
echo
${
RED
}
"Extracting SCL information..."
${
NC
}
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
cd
$USERDIR
"out/"
for
i
in
$(
ls
-d
*
/
)
;
do
for
i
in
$(
ls
-d
*
/
)
;
do
cd
../out/
$i
"SCL"
cd
../out/
$i
"
mask/
SCL"
if
[
!
-d
"json"
]
;
then
if
[
!
-d
"json"
]
;
then
mkdir
json
mkdir
json
fi
fi
SCLimageListToJSON.sh
$USERDIR
"out/"
$i
"SCL/"
$USERDIR
"findProducts.json"
6
SCLimageListToJSON.sh
$USERDIR
"out/"
$i
"
mask/
SCL/"
$USERDIR
"findProducts.json"
6
mv
*
.json json
mv
*
.json json
cd
json
cd
json
tile
=
$(
echo
$i
|
cut
-d
"/"
-f1
)
tile
=
$(
echo
$i
|
cut
-d
"/"
-f1
)
mergeL2ASCL_JSON.py
$USERDIR
"out/"
$i
"SCL/json/"
>
$USERDIR$tile
"_sclData.json"
mergeL2ASCL_JSON.py
$USERDIR
"out/"
$i
"
mask/
SCL/json/"
>
$USERDIR$tile
"_sclData.json"
echo
$tile
echo
$tile
echo
"_sclData.json"
echo
"_sclData.json"
cd
$USERDIR
"
jp2
/"
cd
$USERDIR
"
out
/"
done
done
else
else
echo
"BY DATE"
echo
"BY DATE"
cd
$USERDIR
/jp2/merge_out/SCL
cd
$USERDIR
"out/mask/SCL/"
if
[
!
-d
"json"
]
;
then
if
[
!
-d
"json"
]
;
then
mkdir
json
mkdir
json
fi
fi
SCLimageListToJSON.sh
$USERDIR
"
jp2/merge_out
/SCL/"
$USERDIR
"findProducts.json"
6
SCLimageListToJSON.sh
$USERDIR
"
out/mask
/SCL/"
$USERDIR
"findProducts.json"
6
mv
*
.json json
mv
*
.json json
cd
json
cd
json
mergeL2ASCL_JSON.py
$USERDIR
"
jp2/merge_out
/SCL/json/"
>
$USERDIR
"scl_data.json"
mergeL2ASCL_JSON.py
$USERDIR
"
out/mask
/SCL/json/"
>
$USERDIR
"scl_data.json"
fi
fi
echo
"Archivo"
echo
$USERDIR
#8.-Create Tiles
echo
"Genenado zip..."
echo
${
RED
}
"Creating Tiles..."
${
NC
}
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
cd
$USERDIR
"out/"
for
d
in
$(
ls
-d
*
/
)
;
do
cd
$d
"mask/TCI/"
if
[
!
-d
"tiles"
]
;
then
mkdir
tiles
fi
for
i
in
$(
ls
*
.tif
)
;
do
cd
tiles
gdal2tiles.py ../
$i
cd
..
done
cd
$USERDIR
"out/"
cd
$d
"mask/SCL/"
if
[
!
-d
"tiles"
]
;
then
mkdir
tiles
fi
for
i
in
$(
ls
*
.tif
)
;
do
cd
tiles
gdal2tiles.py ../
$i
cd
..
done
cd
$USERDIR
"out/"
done
else
echo
"BY DATE"
cd
$USERDIR
"out/mask/TCI/"
if
[
!
-d
"tiles"
]
;
then
mkdir
tiles
fi
for
i
in
$(
ls
*
.tif
)
;
do
cd
tiles
gdal2tiles.py ../
$i
cd
..
done
cd
$USERDIR
"out/mask/SCL/"
if
[
!
-d
"tiles"
]
;
then
mkdir
tiles
fi
for
i
in
$(
ls
*
.tif
)
;
do
cd
tiles
gdal2tiles.py ../
$i
cd
..
done
fi
exit
#9.-Create ZIP file
echo
"Compresing Files in "
$USERDIR
"..."
cd
$USERDIR
cd
$USERDIR
zip
-r
myzip
.
--exclude
*
.json
--exclude
*
.zip
--exclude
*
thumbnails
*
--exclude
*
.tif
-x
./jp2
\*
./L2A
\*
\*\*
/
\*
/SCL/
\*
^C
zip
-r
myzip
.
--exclude
*
.json
--exclude
*
.zip
--exclude
*
thumbnails
*
--exclude
*
.tif
-x
./jp2
\*
./L2A
\*
\*\*
/
\*
/SCL/
\*
^C
echo
"
FIN
"
echo
"
END
"
#mv *SCL_60m.tif json
#mv *SCL_60m.tif json
#cd json
#cd json
tools/mergeImages.sh
View file @
de258520
#!/bin/sh
#!/bin/sh
INDIR
=
$1
#
Output filenam
e
INDIR
=
$1
#
Directory with images to merg
e
OUTDIR
=
$2
#Output
filename
OUTDIR
=
$2
#Output
directory
POLYGON
=
$3
#Crop Window
POLYGON
=
$3
#Crop Window
(minX, maxX, minY, maxY)
DIRNAME
=
$(
echo
$INDIR
|
cut
-d
"/"
-f1
)
DIRNAME
=
$(
echo
$INDIR
|
cut
-d
"/"
-f1
)
echo
"INDIR:"
$INDIR
echo
"INDIR:"
$INDIR
echo
"OUTDIR:"
$OUTDIR
echo
"OUTDIR:"
$OUTDIR
...
...
tools/mergeImagesByDirectory.sh
View file @
de258520
...
@@ -7,6 +7,8 @@ DIRNAME=$(echo $JP2DIR | cut -d"/" -f1)
...
@@ -7,6 +7,8 @@ DIRNAME=$(echo $JP2DIR | cut -d"/" -f1)
#echo "POLYGON"
#echo "POLYGON"
#echo $POLYGON
#echo $POLYGON
BOX
=
$(
polygonToBox.py
"
$POLYGON
"
)
BOX
=
$(
polygonToBox.py
"
$POLYGON
"
)
echo
"Polygon BOX"
echo
$BOX
if
[
"$#"
-le
1
]
;
then
if
[
"$#"
-le
1
]
;
then
echo
"Usage "
$0
" <Parent Directory with subdirectories> <POLYGON> [jobs]"
echo
"Usage "
$0
" <Parent Directory with subdirectories> <POLYGON> [jobs]"
exit
exit
...
...
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