2

I am trying to download the Sentinel 2 images over an area of Western Norway. Since the ESA archive is very slow, I am trying to use the Norwegian mirror for Sentinel instead (https://colhub.met.no/#/home).

I manage to get an excel file of the images suitable using the following code (username & password taken out):

from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
import pandas as pd
import logging


logging.basicConfig(format='%(message)s', level='INFO')
api = SentinelAPI('username', 'password', 'https://colhub.met.no/#/home')
dates = '[2018-01-01T00:00:00.000Z TO 2019-07-01T00:00:00.000Z]'
orbit = '117'
footprint = geojson_to_wkt(read_geojson("P:\Ben\hordaland_outline_simp.json"))
cloud = '[0 TO 50]'


products = api.query(footprint, dates,platformname='Sentinel-2',cloudcoverpercentage = cloud, producttype = 'S2MSI1C')


# convert to Pandas DataFrame
products_df = api.to_dataframe(products)
##products_df_sorted = products_df.sort_values(['beginposition', 'orbitdirection'], ascending=[True, True])

file_name = r"G:\Data\Raw\Sentinel\Sentinel2\1_Raw_L2A\Sentinel2_images.xlsx"
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter(file_name, engine='xlsxwriter')
# Convert the dataframe to an XlsxWriter Excel object.
products_df.to_excel(writer, sheet_name='Sheet1')
# Close the Pandas Excel writer and output the Excel file.
writer.save()
print "Excel file with images to be processed has been written to " + file_name

Then I try to download using

api.download_all(products_df)

But I get the error:

Traceback (most recent call last):
  File "C:\Users\bro076\AppData\Roaming\Python\Python27\site-packages\sentinelsat\sentinel.py", line 602, in download_all
product_info = self.download(product_id, directory_path, checksum)
  File "C:\Users\bro076\AppData\Roaming\Python\Python27\site-packages\sentinelsat\sentinel.py", line 493, in download
product_info = self.get_product_odata(id)
  File "C:\Users\bro076\AppData\Roaming\Python\Python27\site-packages\sentinelsat\sentinel.py", line 428, in get_product_odata
values = _parse_odata_response(response.json()['d'])
  File "C:\Users\bro076\AppData\Roaming\Python\Python27\site-packages\sentinelsat\sentinel.py", line 1128, in _parse_odata_response
'Online': product['Online'],
KeyError: 'Online'

I was wondering if some of the parameters need to be tweaked when downloading from colhub.met.no, perhaps since the data is not archived in the long-term storage (Online/Offline) as is the ESA archive.

1

I looks like the 'Online' field in OData is missing in the Norweigian mirror and this raises an error. Apparently this was resolved by setting the defaults to True in a recent bug. A temporary solution would be downgrading the package:


pip install sentinelsat==0.12
| improve this answer | |
  • That does the trick. Thanks for answering in both areas! – user3652893 Jul 17 '19 at 10:20

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.