update

parent 380aa2a8
......@@ -48,7 +48,7 @@ class APISentinel(object):
# self.intersection_th = 30
self.api = SentinelAPI(self.username, self.password, self.URL_Sentinel)
def getProducts(self, area, date, searchParameters):
def getProducts(self, area, date, searchParameters, areaRelation="Intersects"):
"""Gets Sentinel products list that match the search parameters.
Args:
......@@ -67,9 +67,19 @@ class APISentinel(object):
Returns:
OrderedDict: Sentinel Product list found.
Notes:
area_relation : {'Intersects', 'Contains', 'IsWithin'}, optional
What relation to use for testing the AOI. Case insensitive.
- Intersects: true if the AOI and the footprint intersect (default)
- Contains: true if the AOI is inside the footprint
- IsWithin: true if the footprint is inside the AOI
"""
products_list = self.api.query(area, date, area_relation='Intersects', **searchParameters)
products_list = self.api.query(area, date, area_relation=areaRelation, **searchParameters)
return products_list
def downloadProducts(self,products,dir):
......@@ -93,25 +103,7 @@ class APISentinel(object):
for p in productList:
if productList[p]['filename'].find("OPER_PRD") != -1:
del products[p]
# products_down = products_list.copy()
# products_df = self.api.to_dataframe(products_list)
# polyfootprint = ogr.CreateGeometryFromWkt(user_footprint)
# areafootprint = polyfootprint.GetArea()
# for i in range(len(products_df)):
# inputpoly = ogr.CreateGeometryFromWkt(products_df.footprint[i])
# intersectionpoly = polyfootprint.Intersection(inputpoly)
# intersectionpoly_area = intersectionpoly.GetArea()
# por_intersection = (intersectionpoly_area * 100) / areafootprint
# if (por_intersection <= threshold):
# # Deleting element
# del products_down[products_df.uuid[i]]
return products
......
<PAMDataset>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>-0.4615384615384616</HistMin>
<HistMax>12.46153846153846</HistMax>
<BucketCount>13</BucketCount>
<IncludeOutOfRange>0</IncludeOutOfRange>
<Approximate>1</Approximate>
<HistCounts>223|2|2|1|1064|174|893|67|45|19|8|1|1</HistCounts>
</HistItem>
</Histograms>
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="COMPRESSION">JPEG2000</MDI>
</Metadata>
<Metadata>
<MDI key="STATISTICS_APPROXIMATE">YES</MDI>
<MDI key="STATISTICS_MAXIMUM">12</MDI>
<MDI key="STATISTICS_MEAN">4.6384</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">1.8461975625593</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
<PAMDataset>
<SRS>PROJCS["WGS 84 / UTM zone 16N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32616"]]</SRS>
<GeoTransform> 2.0916000000000000e+05, 1.0000000000000000e+01, 0.0000000000000000e+00, 2.3458700000000000e+06, 0.0000000000000000e+00, -1.0000000000000000e+01</GeoTransform>
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="COMPRESSION">JPEG</MDI>
<MDI key="INTERLEAVE">PIXEL</MDI>
<MDI key="SOURCE_COLOR_SPACE">YCbCr</MDI>
</Metadata>
<PAMRasterBand band="1">
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="COMPRESSION">JPEG</MDI>
</Metadata>
</PAMRasterBand>
<PAMRasterBand band="2">
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="COMPRESSION">JPEG</MDI>
</Metadata>
</PAMRasterBand>
<PAMRasterBand band="3">
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="COMPRESSION">JPEG</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
......@@ -29,7 +29,9 @@ def main(argv):
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'])+"]"}, "Contains")
if len(productList)<=0:
print ("No products found with 'Contains' trying with 'Intersects'")
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() ]
......
<PAMDataset>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>-0.4615384615384616</HistMin>
<HistMax>12.46153846153846</HistMax>
<BucketCount>13</BucketCount>
<IncludeOutOfRange>0</IncludeOutOfRange>
<Approximate>1</Approximate>
<HistCounts>118281|375|1762|6524|28005|9873|8645|11659|1529|6235|569|177|10</HistCounts>
</HistItem>
</Histograms>
<Metadata>
<MDI key="STATISTICS_MAXIMUM">12</MDI>
<MDI key="STATISTICS_MEAN">2.0369492470719</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">2.8042144980274</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
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