0

This code used to work using the Python API:

    url = ee.data.makeDownloadUrl(ee.data.getDownloadId({
          'image': image.serialize(),
          'scale': '%d' % scale,
          'filePerBand': 'false',
          'name': 'data',
    }))

It now complains that

   Image as JSON string not supported.

I'm assuming something changed in the API but I can't figure out what I need to change the "example" in the documenation is empty.

Anyone any suggestions?

2 Answers 2

1

Rather than using the low-level ee.data.makeDownloadUrl method, it is simpler to use the ee.Image.getDownloadURL method.

# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0

sample_img = ee.Image('LANDSAT/LT05/C01/T1_TOA/LT05_031034_20110619')
url = sample_img.getDownloadURL({
  'scale':300,
  'filePerBand':False
})

Downloading directly may work for small images, but larger scale downloads should use batch export tasks, using the ee.batch module of the Python client library.

0

You just have to remove the .serialize() method:

 url = ee.data.makeDownloadUrl(ee.data.getDownloadId({
          'image': image,
          'scale': '%d' % scale,
          'filePerBand': 'false',
          'name': 'data',
    }))

Your Answer

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

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