Commit 16363b2d authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

find products

parent 5bcea57a
......@@ -96,7 +96,9 @@ The script works as follows:
"endDate": "20181101",
"clouds":"40",
"productsDir":"/home/geoint/NAS/sentinelImages/L2A/",
"linksDir": "/home/geoint/NAs/merida/"
"linksDir": "/home/geoint/NAS/merida/",
"username":"esausername",
"password":"esapasword"
}
......
{
"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/"
}
......@@ -6,7 +6,9 @@
"endDate": "20181101",
"clouds":"40",
"productsDir":"/home/geoint/NAS/sentinelImages/L2A/",
"linksDir": "/home/geoint/NAS/merida/"
"linksDir": "/home/geoint/NAS/merida/",
"username":"mario-chirinos",
"password":"r4nc0r4u"
}
#!/usr/bin/python
# -*- coding: utf-8 -*-
......@@ -11,12 +11,12 @@ from geosentinel import polygonToBox
from datetime import date
def findSentinelProducts(wkt, startDate, endDate, platform, cloud):
sentinel = APISentinel.APISentinel('asalazarg', 'geo135asg')
#def findSentinelProducts(wkt, startDate, endDate, platform, cloud):
# sentinel = APISentinel.APISentinel('asalazarg', 'geo135asg')
products = sentinel.getProducts(wkt, (startDate, endDate), {"platformname":platform, "cloudcoverpercentage":"[0 TO "+str(cloud)+"]"})
# products = sentinel.getProducts(wkt, (startDate, endDate), {"platformname":platform, "cloudcoverpercentage":"[0 TO "+str(cloud)+"]"})
return products
# return products
def main(argv):
......@@ -26,9 +26,11 @@ def main(argv):
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'])
sentinel = APISentinel.APISentinel(cfg['username'], cfg['password'])
wkt = polygonToBox.getWKTPolygonBoundingBox(cfg['wkt'], True)
# productList = findSentinelProducts(wkt, cfg['startDate'], cfg['endDate'], cfg['platform'], cfg['clouds'])
productList = sentinel.getProducts(wkt, (cfg['startDate'], cfg['endDate']), {"platformname":cfg['platform'], "cloudcoverpercentage":"[0 TO "+str(cfg['clouds'])+"]"})
productsCodes = {"L1C":"L1C","L2A":"L1C"}
fileNames = [productList[k]['filename'].replace("SAFE", "zip").replace(productsCodes[cfg['productLevel']], cfg['productLevel']) for k in productList.keys() ]
inDir = cfg["productsDir"]
......
......@@ -5,9 +5,11 @@ JP2DIR=$2 #JP2 Output Directory
#S2A_MSIL2A_20170515T162341_N0205_R040_T16QBJ_20170515T163103.zip
filepattern=$(echo $FILE | cut -d"_" -f6)"_"$(echo $FILE | cut -d"_" -f3)"_" #T16QBJ_20170515T162341_
tile=$(echo $filepattern | cut -d"_" -f1) #T16QBJ
datetime=$(echo $filepattern | cut -d"_" -f2) #20170515T162341
dateText=$(echo $datetime | cut -d"T" -f1) #20170515
productType=$(echo $filepattern | cut -d"_" -f2) #MSIL2A
tile=$(echo $filepattern | cut -d"_" -f1) #T16QBJ
datetime=$(echo $filepattern | cut -d"_" -f2) #20170515T162341
dateText=$(echo $datetime | cut -d"T" -f1) #20170515
outDir=$JP2DIR$dateText"/"
filePrefix=$outDir$filepattern
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment