2

I am having a go at using the sentinelsat python API to download satellite imagery. However, I am receiving error messages when I try to convert to a pandas dataframe. This code works and downloads my requested sentinel satellite images:

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

api = SentinelAPI('*****', '*****', 'https://scihub.copernicus.eu/dhus')

footprint = geojson_to_wkt(read_geojson('testAPIpoly.geojson'))

products = api.query(footprint, cloudcoverpercentage = (0,10))

#this works  
api.download_all(products)

However if I instead attempt to convert to a pandas dataframe

#api.download_all(products)

#this does not work
products_df = api.to_dataframe(products)

api.download_all(products_df)

I receive an extensive error message that includes

"sentinelsat.sentinel.SentinelAPIError: HTTP status 500 Internal Server Error: InvalidKeyException : Invalid key (processed) to access Products "

(where processed is also replaced with title, platformname, processingbaseline, etc.). I've tried a few different ways to convert to a dataframe and filter/sort results and have received an error message every time (note: I have pandas/geopandas installed). How can I convert to a dataframe and filter/sort with the sentinelsat API?

Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
dave
  • 23
  • 4

1 Answers1

1

Instead of

api.download_all(products_df)

try

api.download_all(products_df.index)
Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
  • Thanks-- this worked. From the documentation, they have `api.download_all(products_df_sorted['id'])` which returns me a "KeyError: 'id'". Why? – dave Jul 11 '18 at 08:57
  • You are very welcome to *accept* the answer - see [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) – Ioannis Nasios Jul 11 '18 at 09:07
  • Done. Any idea on why the indexing from the documentation is not working? – dave Jul 11 '18 at 09:11
  • I guess the creators of sentinelsat package meant to create a column in the dataframe named 'id' where ids would be stored but instead ids are stored as row names (index). – Ioannis Nasios Jul 11 '18 at 09:21
  • The [docs](https://sentinelsat.readthedocs.io/en/stable/api.html?highlight=products_df_sorted) point to using `api.download_all(df.index)` and have been for some time. Where did you find the example using `df['id']` @dave? – Kersten May 27 '19 at 09:48
  • The docs were changed when the error was pointed out [here](https://github.com/sentinelsat/sentinelsat/issues/216#issuecomment-404136389) – dave Jun 17 '19 at 18:39