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
8eb0aa57
Commit
8eb0aa57
authored
Apr 20, 2018
by
Pedro Alfonso Ramirez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unzip
parent
2cefd271
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
16 deletions
+37
-16
unzip_sentinel_files
examples/unzip_sentinel_files
+3
-3
ui_utils.py
geosentinel/ui_utils.py
+34
-13
No files found.
examples/unzip_sentinel_files
View file @
8eb0aa57
...
...
@@ -23,7 +23,7 @@ Example of unzip Sentinel files in a specific directory
"""
from
argparse
import
ArgumentParser
from
geosentinel.ui_utils
import
(
find_files
,
unzip
,
SENTINEL_UNZIP_ARGUMENTS
)
from
geosentinel.ui_utils
import
(
find_files
_Sentinel
,
unzip_files_Sentinel
,
SENTINEL_UNZIP_ARGUMENTS
)
def
main
():
...
...
@@ -39,8 +39,8 @@ def main():
args
=
parser
.
parse_args
()
list_files
=
find_files
(
args
)
unzip
(
list_files
,
args
)
list_files
=
find_files
_Sentinel
(
args
)
unzip
_files_Sentinel
(
list_files
,
args
)
#print list_files
...
...
geosentinel/ui_utils.py
View file @
8eb0aa57
...
...
@@ -26,9 +26,11 @@ Variables:
Functions:
* "find_files" - Discover Sentinel files in directory
* "find_files_Sentinel" - Discover Sentinel files in directory
* "unzip_files_Sentinel" - Unzip Sentinel files in directory
* "download_sentinel_mages" - Calibrate chessboard images discovered in a folder
* "check_existing_directory" - Check out if the folder exist. Create folder if it does not exist
* "check_existing_productType" - Check args if exist
* "select_products" - # Select products that their intersection area is less than a certain percentage threshold
"""
...
...
@@ -80,30 +82,49 @@ SENTINEL_UNZIP_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel fi
SENTINEL_UNZIP_ARGUMENTS
.
add_argument
(
"plattform"
,
help
=
"Sentinel-1 or Sentinel-2"
)
SENTINEL_UNZIP_ARGUMENTS
.
add_argument
(
"product_type"
,
help
=
"sentinel product type {SM_SLC, SM_GRDF, SM_GRDH, SM_GRDM, IW_SLC, IW_GRDH, IW_GDRM, EW_SLC, EW_GRDH, EW_GRDM, WV_SLC, WV_GRDM, MSIL1C, OPER_PRD }"
)
SENTINEL_UNZIP_ARGUMENTS
.
add_argument
(
"product_type"
,
help
=
"sentinel product type {
all,
SM_SLC, SM_GRDF, SM_GRDH, SM_GRDM, IW_SLC, IW_GRDH, IW_GDRM, EW_SLC, EW_GRDH, EW_GRDM, WV_SLC, WV_GRDM, MSIL1C, OPER_PRD }"
)
def
check_existing_productType
(
product
,
flag
):
if
(
flag
==
1
):
plattform
=
[
'Sentinel-1'
,
'sentinel-1'
,
'Sentinel-2'
,
'sentinel-2'
]
findProduct
=
product
in
plattform
if
not
findProduct
:
print
product
+
" not exist"
sys
.
exit
()
if
(
flag
==
2
):
product_type
=
[
"all"
,
"SM_SLC"
,
"SM_GRDF"
,
"SM_GRDH"
,
"SM_GRDM"
,
"IW_SLC"
,
"IW_GRDH"
,
"IW_GDRM"
,
"EW_SLC"
,
"EW_GRDH"
,
"EW_GRDM"
,
"WV_SLC"
,
"WV_GRDM"
,
"MSIL1C"
,
"OPER_PRD"
]
findProduct
=
product
in
product_type
if
not
findProduct
:
print
product
+
" not exist"
sys
.
exit
()
def
find_files
(
args
):
check_existing_directory
(
args
.
folder
,
2
)
def
find_files_Sentinel
(
args
):
folder
=
args
.
folder
satelite
=
args
.
plattform
satellite
=
args
.
plattform
product_typ
=
args
.
product_type
check_existing_directory
(
folder
,
2
)
check_existing_productType
(
satellite
,
1
)
check_existing_productType
(
product_typ
,
2
)
files
=
os
.
listdir
(
folder
)
if
(
satelite
!=
"Sentinel-1"
)
or
(
satelite
!=
"sentinel-1"
)
or
(
satelite
==
"Sentinel-2"
)
or
(
satelite
==
"sentinel-2"
):
print
satelite
+
" not exist"
sys
.
exit
()
if
(
args
.
product_type
==
"all"
):
namfil1
=
'S1A_'
namfil2
=
'S1B_'
namfil3
=
'S2A_'
namfil4
=
'S2B_'
files
=
[
f
for
f
in
files
if
f
.
startswith
(
namfil1
)
or
f
.
startswith
(
namfil2
)
or
f
.
startswith
(
namfil3
)
or
f
.
startswith
(
namfil4
)]
else
:
if
(
satel
ite
==
"Sentinel-1"
)
or
(
sate
lite
==
"sentinel-1"
):
if
(
satel
lite
==
"Sentinel-1"
)
or
(
satel
lite
==
"sentinel-1"
):
namfil1
=
'S1A_'
+
args
.
product_type
namfil2
=
'S1B_'
+
args
.
product_type
if
(
satel
ite
==
"Sentinel-2"
)
or
(
sate
lite
==
"sentinel-2"
):
if
(
satel
lite
==
"Sentinel-2"
)
or
(
satel
lite
==
"sentinel-2"
):
namfil1
=
'S2A_'
+
args
.
product_type
namfil2
=
'S2B_'
+
args
.
product_type
files
=
[
f
for
f
in
files
if
f
.
startswith
(
namfil1
)
or
f
.
startswith
(
namfil2
)]
if
(
len
(
files
)
==
0
):
if
(
len
(
files
)
==
0
):
print
"Files not found..."
return
files
def
unzip
(
list_files
,
args
):
def
unzip
_files_Sentinel
(
list_files
,
args
):
for
image
in
list_files
:
print
"Unzziped... "
,
image
File
=
args
.
folder
+
"
\\
"
+
image
...
...
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