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
0ab2124d
Commit
0ab2124d
authored
Oct 04, 2018
by
Mario Chirinos Colunga
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find products
parent
9b3a3ac7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
22 deletions
+38
-22
README.md
README.md
+16
-1
findproducts.json
examples/findproducts.json
+12
-0
findProducts.py
geosentinel/findProducts.py
+10
-21
No files found.
README.md
View file @
0ab2124d
...
...
@@ -87,8 +87,23 @@ The script works as follows:
### Example
```
json
{
"wkt"
:
"POLYGON((-89.62955474853516 21.05230266883862,-89.55093383789061 21.05230266883862,-89.52930450439452 20.965126493194475,-89.6484375 20.873408465645696,-89.72877502441405 20.95294341625548,-89.65805053710938 21.056788298627097,-89.62955474853516 21.05230266883862))"
,
"platform"
:
"Sentinel-2"
,
"productLevel"
:
"L2A"
,
"startDate"
:
"20181001"
,
"endDate"
:
"20181101"
,
"clouds"
:
"40"
,
"productsDir"
:
"/home/geoint/NAS/sentinelImages/L2A/"
,
"linksDir"
:
"/home/geoint/NAs/merida/"
}
```
## Extract Images from Product ZIP File (`tools/L2AProductListExtractData.sh`)
```
bash
findProducts.py
"POLYGON((-89.62955474853516 21.05230266883862,-89.55093383789061 21.05230266883862,-89.52930450439452 20.965126493194475,-89.6484375 20.873408465645696,-89.72877502441405 20.95294341625548,-89.65805053710938 21.056788298627097,-89.62955474853516 21.05230266883862))"
20181001 20181101 Sentinel-2 30 /home/geoint/NAS/sentinelImages/L2A/ /home/geoint/NAS/merida/
findProducts.py
cfg.json
```
## Extract Images from Product ZIP File (`tools/L2AProductListExtractData.sh`)
...
...
examples/findproducts.json
0 → 100644
View file @
0ab2124d
{
"wkt"
:
"POLYGON((-89.62955474853516 21.05230266883862,-89.55093383789061 21.05230266883862,-89.52930450439452 20.965126493194475,-89.6484375 20.873408465645696,-89.72877502441405 20.95294341625548,-89.65805053710938 21.056788298627097,-89.62955474853516 21.05230266883862))"
,
"platform"
:
"Sentinel-2"
,
"productLevel"
:
"L2A"
,
"startDate"
:
"20181001"
,
"endDate"
:
"20181101"
,
"clouds"
:
"40"
,
"productsDir"
:
"/home/geoint/NAS/sentinelImages/L2A/"
,
"linksDir"
:
"/home/geoint/NAs/merida/"
}
geosentinel/findProducts.py
View file @
0ab2124d
...
...
@@ -3,9 +3,6 @@
import
sys
,
os
import
json
from
contextlib
import
contextmanager
import
contextlib
sys
.
path
.
append
(
'/home/geoint/GeoSentinel'
)
from
geosentinel
import
APISentinel
...
...
@@ -13,15 +10,6 @@ from geosentinel import polygonToBox
from
datetime
import
date
#@contextmanager
#def suppress_stdout():
# with open(os.devnull, "w") as devnull:
# old_stdout = sys.stdout
# sys.stdout = devnull
# try:
# yield
# finally:
# sys.stdout = old_stdout
def
findSentinelProducts
(
wkt
,
startDate
,
endDate
,
platform
,
cloud
):
sentinel
=
APISentinel
.
APISentinel
(
'asalazarg'
,
'geo135asg'
)
...
...
@@ -33,17 +21,19 @@ def findSentinelProducts(wkt, startDate, endDate, platform, cloud):
def
main
(
argv
):
if
len
(
sys
.
argv
)
!=
8
:
print
(
"Usage: "
+
argv
[
0
]
+
" <
WKT Polygon> <Start Date> <End Date> <Platform> <Maximum Cloud
%
> <Source> <Destination
>"
)
print
(
"Usage: "
+
argv
[
0
]
+
" <
JSON File
>"
)
else
:
# with suppress_stdout():
# with contextlib.redirect_stdout(None):
wkt
=
polygonToBox
.
getWKTPolygonBoundingBox
(
sys
.
argv
[
1
],
True
)
productList
=
findSentinelProducts
(
wkt
,
sys
.
argv
[
2
],
sys
.
argv
[
3
],
sys
.
argv
[
4
],
sys
.
argv
[
5
])
jsonFile
=
open
(
argv
[
1
])
.
read
()
cfg
=
json
.
loads
(
jsonFile
)
wkt
=
polygonToBox
.
getWKTPolygonBoundingBox
(
cfg
[
'wkt'
],
True
)
productList
=
findSentinelProducts
(
wkt
,
cfg
[
'startDate'
],
cfg
[
'endDate'
],
cfg
[
'platform'
],
cfg
[
'clouds'
])
fileNames
=
[
productList
[
k
][
'filename'
]
.
replace
(
"SAFE"
,
"zip"
)
.
replace
(
"L1C"
,
"L2A"
)
for
k
in
productList
.
keys
()
]
fileNames
=
[
productList
[
k
][
'filename'
]
.
replace
(
"SAFE"
,
"zip"
)
.
replace
(
productList
[
k
][
'filename'
][:
3
],
cfg
[
'productLevel'
]
)
for
k
in
productList
.
keys
()
]
inDir
=
sys
.
argv
[
6
]
outdir
=
sys
.
argv
[
7
]
inDir
=
cfg
[
"productsDir"
]
outdir
=
cfg
[
"linksDir"
]
dirList
=
os
.
listdir
(
inDir
)
matchingProducts
=
set
(
fileNames
)
.
intersection
(
set
(
dirList
))
...
...
@@ -53,7 +43,6 @@ def main(argv):
for
f
in
matchingProducts
:
print
(
f
)
os
.
system
(
"ln -s "
+
inDir
+
f
+
" "
+
outdir
+
f
)
# print ("ln -s " + inDir+f + " " + outdir+f)
print
(
str
(
len
(
matchingProducts
))
+
" Linked to "
+
outdir
)
if
__name__
==
"__main__"
:
...
...
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