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
Show 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):
os
.
chdir
(
dir
)
# self.api.download_all(products)
for
p
in
products
:
print
(
products
[
p
][
'filename'
])
self
.
api
.
download
(
p
)
def
filterProducts
(
self
,
productList
):
...
...
geosentinel/findProducts.py
View file @
de258520
...
...
@@ -59,10 +59,9 @@ def main(argv):
while
text
!=
"yes"
and
text
!=
"no"
:
text
=
raw_input
(
"Do you want to download this products to "
+
rawDir
+
" ? (yes, no)"
)
if
text
==
"yes"
:
sentinel
.
downloadProducts
(
productList
,
rawDir
)
#
sentinel.downloadProducts(productList,rawDir)
print
(
"L1CProductListToL2A.sh "
+
rawDir
+
" "
+
inDir
+
" 1"
)
os
.
system
(
"L1CProductListToL2A.sh "
+
rawDir
+
" "
+
inDir
+
" 1"
)
# os.system("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
text
=
""
while
text
!=
"yes"
and
text
!=
"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 @@
PRODCUTSDIR
=
$1
#Products Intput directory
JP2DIR
=
$2
#JP2 Output Directory
JOBS
=
${
3
:-
1
}
BYTILE
=
${
4
:-
0
}
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}
# exit
#fi
echo
"
Iniciando proceso
..."
echo
"
Starting Process
..."
echo
$USERDIR
"findProducts.json"
wkt
=
$(
getJSONparameter.py
$USERDIR
"findProducts.json"
wkt
)
RED
=
'\033[0;31m'
...
...
@@ -19,6 +19,12 @@ echo $wkt
echo
$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
echo
"Linking Products..."
if
[
!
-d
"L2A"
]
;
then
...
...
@@ -27,7 +33,7 @@ fi
cd
L2A
rm
*
cd
..
echo
yes
| findProducts.py
$USERDIR
"findProducts.json"
yes
yes
| findProducts.py
$USERDIR
"findProducts.json"
#2.- Extract Images
...
...
@@ -35,11 +41,18 @@ echo "Extracting JP2 Images..."
if
[
!
-d
"jp2"
]
;
then
mkdir
jp2
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
echo
"
*************************************************
Merging Images..."
echo
"
\n
Merging Images..."
if
[
$BYTILE
-ne
"0"
]
;
then
echo
"BY TILE"
cd
$USERDIR
"jp2/"
...
...
@@ -51,22 +64,65 @@ if [ $BYTILE -ne "0" ]; then
if
[
!
-d
"../out/"
$i
]
;
then
mkdir
"../out/"
$i
fi
"mergeImagesByDirectory.sh"
$USERDIR
"jp2/"
$i
../../../out/
$i
"
$wkt
"
mergeImagesByDirectory.sh
$USERDIR
"jp2/"
$i
../../../out/
$i
"
$wkt
"
done
else
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
#4.- Mask raster with shape file
echo
"
\n
Applying Mask..."
#4.- Delete images with few data
echo
"****************************************************** Deleting Images..."
if
[
$BYTILE
-ne
"0"
]
;
then
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
cd
../out/
$i
cd
$i
"mask"
echo
$i
if
[
!
-d
"SCL"
]
;
then
mkdir
SCL
...
...
@@ -82,17 +138,12 @@ if [ $BYTILE -ne "0" ]; then
fileprefix
=
$(
echo
$scl
|
(
cut
-d
"_"
-f1
)
)
cp
../
$fileprefix
"_TCI_60m.tif"
../TCI/
$fileprefix
"_TCI_60m.tif"
done
cd
../TCI
mogrify
-format
jpg
-quality
100
*
.tif
mkdir
thumbnails
mogrify
-path
./thumbnails
-resize
10%
*
.jpg
cd
$USERDIR
"out/"
cd
$USERDIR
"jp2/"
done
else
echo
"BY DATE"
cd
jp2/merge_out/
cd
$USERDIR
"out/mask/"
if
[
!
-d
"SCL"
]
;
then
mkdir
SCL
fi
...
...
@@ -106,51 +157,145 @@ else
for
scl
in
$(
ls
*
.tif
)
do
fileprefix
=
$(
echo
$scl
|
(
cut
-d
"_"
-f1
)
)
cp
../
$fileprefix
"_TCI_10m.tif"
../TCI/
$fileprefix
"_TCI_10m.tif"
done
cp
../
$fileprefix
"_TCI_60m.tif"
../TCI/
$fileprefix
"_TCI_60m.tif"
cd
../TCI
echo
"mogrify -format jpg -quality 100 *.tif"
done
fi
#6.-Creating Thumbnails
echo
"Creating Thumbnails"
if
[
$BYTILE
-ne
"0"
]
;
then
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
mkdir
thumbnails
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
#5.-Extract SCL information
echo
"**************************************************** Extracting SCL information..."
cd
$USERDIR
"jp2/"
#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
cd
../out/
$i
"SCL"
cd
../out/
$i
"
mask/
SCL"
if
[
!
-d
"json"
]
;
then
mkdir
json
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
cd
json
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
"_sclData.json"
cd
$USERDIR
"
jp2
/"
cd
$USERDIR
"
out
/"
done
else
echo
"BY DATE"
cd
$USERDIR
/jp2/merge_out/SCL
cd
$USERDIR
"out/mask/SCL/"
if
[
!
-d
"json"
]
;
then
mkdir
json
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
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
echo
"Archivo"
echo
$USERDIR
echo
"Genenado zip..."
#8.-Create Tiles
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
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
#cd json
tools/mergeImages.sh
View file @
de258520
#!/bin/sh
INDIR
=
$1
#
Output filenam
e
OUTDIR
=
$2
#Output
filename
POLYGON
=
$3
#Crop Window
INDIR
=
$1
#
Directory with images to merg
e
OUTDIR
=
$2
#Output
directory
POLYGON
=
$3
#Crop Window
(minX, maxX, minY, maxY)
DIRNAME
=
$(
echo
$INDIR
|
cut
-d
"/"
-f1
)
echo
"INDIR:"
$INDIR
echo
"OUTDIR:"
$OUTDIR
...
...
tools/mergeImagesByDirectory.sh
View file @
de258520
...
...
@@ -7,6 +7,8 @@ DIRNAME=$(echo $JP2DIR | cut -d"/" -f1)
#echo "POLYGON"
#echo $POLYGON
BOX
=
$(
polygonToBox.py
"
$POLYGON
"
)
echo
"Polygon BOX"
echo
$BOX
if
[
"$#"
-le
1
]
;
then
echo
"Usage "
$0
" <Parent Directory with subdirectories> <POLYGON> [jobs]"
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