defra-data / EODS-API

A collection of example scripts for Defra Core and ALB users of the Earth Observation Data Service. You can find example videos on how to use these scripts at https://earthobs.defra.gov.uk/help/
MIT License
5 stars 1 forks source link

S2A + S2B products downloaded via API are significantly larger than they should be #6

Closed tyhayward closed 3 years ago

tyhayward commented 3 years ago

Files downloaded from the API are almost always 2,478,089kb or 2,335,209kb whereas corresponding files from the webportal are approx 600-800mb in size.

I cant see why this is as they should be the same file(s) - i assume it an issue with the API

samfranklin commented 3 years ago

@tyhayward thanks for this. The data, as in the raw pixel values contianed in the primary geotiff is identical between the two download methods. However, the difference you observe is that the current API can only access the data via an OGC Web Processing Service (WPS).

What happens is this:

To workaround this limitation, I've actually included some rasterio commands which add the optimisations back into the downloaded result, see eods-example3-query-eods-download-results-mosaic-s2s-with-rasterio.ipynb

You could adapt the cells (copied below):

# add overviews (pyramids) to the download this has to be "inplace" change
rio_overviews_cmd = ['rio', 'overview', '--build', '2,4,8,16', <input-raw-download-file>]
subprocess.run(rio_overviews_cmd, capture_output=True)

# convert the wps "raw" geotiff to optimised format geotiff
rio_convert_cmd = [
    'rio',
    'convert',
    <input-raw-download-file>,
    <output-cog-format-geotiff>,
    '--co',
    'compress=LZW',
    '--co',
    'tiled=true',
    '--co',
    'blockxsize=256',
    '--co',
    'blockysize=256',
]
subprocess.run(rio_convert_cmd, capture_output=True)

We have a story in our backlog to deliver the COG (optimised) format geotiff directly to the user via the API. Please feel free to complete this feedback form to register that you would like this feature, feedback form here https://defragroup.eu.qualtrics.com/jfe/form/SV_cNHH8Hp5uXOCLiJ