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?

1 Answer 1

1

Instead of

api.download_all(products_df)

try

api.download_all(products_df.index)
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks-- this worked. From the documentation, they have api.download_all(products_df_sorted['id']) which returns me a "KeyError: 'id'". Why?
You are very welcome to accept the answer - see What should I do when someone answers my question?
Done. Any idea on why the indexing from the documentation is not working?
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).
The docs point to using api.download_all(df.index) and have been for some time. Where did you find the example using df['id'] @dave?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.