Commit 0ab2124d authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

find products

parent 9b3a3ac7
...@@ -87,8 +87,23 @@ The script works as follows: ...@@ -87,8 +87,23 @@ The script works as follows:
### Example ### 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 ```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`) ## Extract Images from Product ZIP File (`tools/L2AProductListExtractData.sh`)
......
{
"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/"
}
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
import sys, os import sys, os
import json import json
from contextlib import contextmanager
import contextlib
sys.path.append('/home/geoint/GeoSentinel') sys.path.append('/home/geoint/GeoSentinel')
from geosentinel import APISentinel from geosentinel import APISentinel
...@@ -13,15 +10,6 @@ from geosentinel import polygonToBox ...@@ -13,15 +10,6 @@ from geosentinel import polygonToBox
from datetime import date 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): def findSentinelProducts(wkt, startDate, endDate, platform, cloud):
sentinel = APISentinel.APISentinel('asalazarg', 'geo135asg') sentinel = APISentinel.APISentinel('asalazarg', 'geo135asg')
...@@ -33,17 +21,19 @@ def findSentinelProducts(wkt, startDate, endDate, platform, cloud): ...@@ -33,17 +21,19 @@ def findSentinelProducts(wkt, startDate, endDate, platform, cloud):
def main(argv): def main(argv):
if len(sys.argv) != 8: 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: else:
# with suppress_stdout(): jsonFile=open(argv[1]).read()
# with contextlib.redirect_stdout(None): cfg = json.loads(jsonFile)
wkt = polygonToBox.getWKTPolygonBoundingBox(sys.argv[1], True)
productList = findSentinelProducts(wkt, sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) 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] inDir = cfg["productsDir"]
outdir = sys.argv[7] outdir = cfg["linksDir"]
dirList = os.listdir(inDir) dirList = os.listdir(inDir)
matchingProducts = set(fileNames).intersection(set(dirList)) matchingProducts = set(fileNames).intersection(set(dirList))
...@@ -53,7 +43,6 @@ def main(argv): ...@@ -53,7 +43,6 @@ def main(argv):
for f in matchingProducts: for f in matchingProducts:
print (f) print (f)
os.system("ln -s " + inDir+f + " " + outdir+f) os.system("ln -s " + inDir+f + " " + outdir+f)
# print ("ln -s " + inDir+f + " " + outdir+f)
print (str(len(matchingProducts)) + " Linked to " + outdir) print (str(len(matchingProducts)) + " Linked to " + outdir)
if __name__ == "__main__": if __name__ == "__main__":
......
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