0

I am trying to compute NDVI of an image collection with 10 images in it. I created an ndvi function and mapped that over the image collection. After that I want reduce the collection to a single image with median reducer. However earth engine returns an image with no values. When I select the first image from the mapped collection, that loads just fine in QGIS however with any reducer / mosaic it returns nothing

Please suggest how to fix it.

This is my code https://colab.research.google.com/drive/1nD-AIZgzEQOs2Vf8G749o87A0RXiIrMj?usp=sharing

# imports
!pip install -U earthengine-api --no-deps --quiet
import ee
from google.colab import auth
auth.authenticate_user()
ee.Authenticate()
ee.Initialize()

# Study Area
xMin = 70;
yMin = 33;
xMax = 70.3;
yMax = 33.3;
area = ee.Geometry.Rectangle([[xMin, yMin],[xMax, yMax]])

# Filtering an image Collection
s2 = ee.ImageCollection("COPERNICUS/S2_SR").filterBounds(area).filterDate('2022-05-01','2022-05-25')
print(s2.getInfo())
print(s2.first().bandNames().getInfo())

# mapping over image collection
def getNDVI(image):
    # Normalized difference vegetation index (NDVI)
    ndvi = image.normalizedDifference(['B8','B4']).rename("ndvi")
    return(ndvi.copyProperties(image,['system:time_start','system:time_end']))
mapped = s2.map(getNDVI)
print(mapped.size().getInfo())

# Reducing to median image
median = mapped.median().clip(area)
print(median.getInfo())

#downloading the tiff
dl = median.getDownloadURL()
print(dl)

This is how the first NDVI image appears from the mapped collection First image from the NDVI collection

Median image with no values Median Image With No Values

1 Answer 1

1

You can specify the getDownloadURL() params and specify the scale you want to export your imagery to. For more details, look here.

dl = median.getDownloadURL({'scale': 300})
3
  • Thank you once again Daniel... Actually I am new to GEE Python API so needed that. It worked. I think max limit for getDownloadURL is 32 MB can I increase that limit?
    – MS09
    Nov 25, 2022 at 13:54
  • I don't believe you can, but I could be wrong. Nov 25, 2022 at 15:21
  • 1
    Maybe Noel's article on downloads can be useful: gorelick.medium.com/fast-er-downloads-a2abd512aa26 Nov 25, 2022 at 15:23

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.