example

parent ff2eef3c
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
form ../geosentinel import APISentienel sys.path.append('../')
from geosentinel import APISentinel
from datetime import date
sentinel = APISentinel.APISentinel('asalazarg', 'geo135asg') sentinel = APISentinel.APISentinel('asalazarg', 'geo135asg')
#products = sentinel.getProducts("POLYGON((-89.99450683593753 21.279137394108716,-89.13757324218751 21.2996106049456,-89.30236816406251 20.68418377935238,-90.0494384765625 20.715015145512098,-89.99450683593753 21.279137394108716))", ('20151219', date(2015,12,29)), {"platformname":"Sentinel-2"}) polygon = "POLYGON((-89.79030210118333 21.122657323983717,-89.77308220413153 21.122657323983717,-89.77308220413153 21.140540053466538,-89.79030210118333 21.140540053466538,-89.79030210118333 21.122657323983717))"
products = sentinel.getProducts(polygon, ('20150101', '20180517'), {"platformname":"Sentinel-2", "cloudcoverpercentage":"[0 TO 0]"})
print len(products) print len(products)
#sentinel.downloadProducts(products,dir) #sentinel.downloadProducts(products,dir)
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
""" """
Install: Install:
$ pip install sentinelsat $ sudo pip install sentinelsat
$ sudo apt-get install libgdal-dev
Example: Example:
...@@ -14,7 +15,7 @@ import os ...@@ -14,7 +15,7 @@ import os
from sentinelsat.sentinel import SentinelAPI from sentinelsat.sentinel import SentinelAPI
from datetime import date from datetime import date
from collections import OrderedDict from collections import OrderedDict
from osgeo import ogr #from osgeo import ogr
class APISentinel(object): class APISentinel(object):
...@@ -81,39 +82,28 @@ class APISentinel(object): ...@@ -81,39 +82,28 @@ class APISentinel(object):
self.api.download_all(products) self.api.download_all(products)
def filterProducts(self, products_list, user_footprint, threshold): # def filterProducts(self, products_list, user_footprint, threshold):
products_down = OrderedDict() # products_down = OrderedDict()
products_down = products_list.copy() # products_down = products_list.copy()
products_df = self.api.to_dataframe(products_list) # products_df = self.api.to_dataframe(products_list)
polyfootprint = ogr.CreateGeometryFromWkt(user_footprint) # polyfootprint = ogr.CreateGeometryFromWkt(user_footprint)
areafootprint = polyfootprint.GetArea() # areafootprint = polyfootprint.GetArea()
for i in range(len(products_df)): # for i in range(len(products_df)):
inputpoly = ogr.CreateGeometryFromWkt(products_df.footprint[i]) # inputpoly = ogr.CreateGeometryFromWkt(products_df.footprint[i])
intersectionpoly = polyfootprint.Intersection(inputpoly) # intersectionpoly = polyfootprint.Intersection(inputpoly)
intersectionpoly_area = intersectionpoly.GetArea() # intersectionpoly_area = intersectionpoly.GetArea()
por_intersection = (intersectionpoly_area * 100) / areafootprint # por_intersection = (intersectionpoly_area * 100) / areafootprint
if (por_intersection <= threshold): # if (por_intersection <= threshold):
# Deleting element # # Deleting element
del products_down[products_df.uuid[i]] # del products_down[products_df.uuid[i]]
return products_down # return products_down
sentinel = APISentinel('asalazarg', 'geo135asg')
dir="make1"
polygon = "POLYGON((-89.81053770202163 21.11585680707654,-89.75755340340068 21.11585680707654,-89.75755340340068 21.15331224168125,-89.81053770202163 21.15331224168125,-89.81053770202163 21.11585680707654))"
options = {"platformname": "Sentinel-2", "cloudcoverpercentage": "[0 TO 30]"} #, "footprint": "Intersects("+polygon+")"}
print options
products = sentinel.getProducts(polygon, ('20150801', date(2018,05,15)), options)
print len(products)
products = sentinel.filterProducts(products, polygon, 95)
print len(products)
sentinel.downloadProducts(products,dir)
...@@ -19,25 +19,5 @@ ...@@ -19,25 +19,5 @@
""" """
Utilities for GeoSentinel.
Modules: """
* "products" - Sentinel products
* "ui_utils" - Utilities for user interaction
* "exceptions" - Various exceptions
Sentinel products
******************
.. automodule:: geosentinel.products
User interface utilities
************************
.. automodule:: geosentinel.ui_utils
Exceptions
**********
.. automodule:: geosentinel.exceptions
"""
\ No newline at end of file
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