2

Based on the documentation here, I wrote the following script:

from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date
api = SentinelAPI('user name', 'password', 'https://scihub.copernicus.eu/dhus')
polygon = r"C:\fields\filed1.geojson"
footprint = geojson_to_wkt(read_geojson(polygon))

products = api.query(footprint,
                     date = ('20170801','20170830'),
                     platformname = 'Sentinel-2',
                     cloudcoverpercentage = (0,30))

products_df = api.to_dataframe(products)

I got the expected result. I'm trying to do the same thing but the search needs to be based upon x,y coordinates.

I read here that I just need to provide the x,y coordinate (as a tuple) to the footprint so I tried:

from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date

api = SentinelAPI('user name', 'password', 'https://scihub.copernicus.eu/dhus')
footprint = (41.9000, 12.5000)

products = api.query(footprint,
                     date = ('20170801','20170830'),
                     platformname = 'Sentinel-2',
                     cloudcoverpercentage = (0,30))

products_df = api.to_dataframe(products)

and I get an error:

SentinelAPIError                          Traceback (most recent call last)
<ipython-input-56-98f8dc400863> in <module>()
      8                      date = ('20170801','20170830'),
      9                      platformname = 'Sentinel-2',
---> 10                      cloudcoverpercentage = (0,30))
     11 
     12 products_df = api.to_dataframe(products)

C:\Users\Ran\Anaconda2\lib\site-packages\sentinelsat\sentinel.pyc in query(self, area, date, raw, area_relation, order_by, limit, offset, **keywords)
    132                           order_by, limit, offset, query)
    133         formatted_order_by = _format_order_by(order_by)
--> 134         response, count = self._load_query(query, formatted_order_by, limit, offset)
    135         self.logger.info("Found %s products", count)
    136         return _parse_opensearch_response(response)

C:\Users\Ran\Anaconda2\lib\site-packages\sentinelsat\sentinel.pyc in _load_query(self, query, order_by, limit, offset)
    240 
    241     def _load_query(self, query, order_by=None, limit=None, offset=0):
--> 242         products, count = self._load_subquery(query, order_by, limit, offset)
    243 
    244         # repeat query until all results have been loaded

C:\Users\Ran\Anaconda2\lib\site-packages\sentinelsat\sentinel.pyc in _load_subquery(self, query, order_by, limit, offset)
    282                 # returned as the total results value when the query string was incorrect.
    283                 raise SentinelAPIError(
--> 284                     'Invalid query string. Check the parameters and format.', response)
    285             total_results = int(json_feed['opensearch:totalResults'])
    286         except (ValueError, KeyError):

SentinelAPIError: HTTP status 200 OK: Invalid query string. Check the parameters and format

How can I perform that?

2

I had the same situation and downloaded everything from command line using sentinelsat on Windows 64. My steps are:

  1. Extract bounding box of your polygon as GeoJSON (in QGIS-->convert from shapefile to GeoJSON). You need 4 points that make up your polygon, even if it has another shape.
  2. Open anaconda prompt (python version>=3)
  3. pip install sentinelsat
  4. cd \your_folder where you want to download
  5. sentinelsat -u your username -p your password -g \path\to\polygon.geojson -s start_of_interval -e end_of_interval --sentinel 2 --cloud 40 -d

This last expression downloads all Sentinel 2 images with a max of 40% cloud coverage.

2
  • What do I do if my polygon contains more (or less) than 4 points? can I choose between sentinel-2 products (i.e., TOA or surface reflectance)?
    – user88484
    Jan 19 '19 at 9:59
  • Use the bounding box in QGis, which extracts a polygon made of 4 corners that enclose your entire polygon. Mar 8 '19 at 21:21
0

sentinelsat accepts any WKT geometry as area parameter. If you want to query images that intersect with a point you would do:

aoi = 'POINT (41.9 12.5)'
products = api.query(aoi,
                     date = ('20170801','20170830'),
                     platformname = 'Sentinel-2',
                     cloudcoverpercentage = (0,30))

See also the documentation of the Python API: https://sentinelsat.readthedocs.io/en/stable/api.html#sentinelsat.SentinelAPI.query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.