Skip to main content
2 of 2
deleted 38 characters in body
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Exporting a time series of images in an image collection from GEE using Python

I'm having trouble with exporting images from NASA/HLS/HLSL30/v002 image collection to Drive.

This produces a map of the image I want to make:

# Applies scaling factors.
def apply_scale_factors(image):
  thermal_bands = image.select('B10').multiply(0.00341802).add(149.0)
  return image.addBands(
      thermal_bands, None, True
  )

visualization = {
    'bands': ['B4', 'B3', 'B2'],
    'min': 0.0,
    'max': 0.3,
}
m = geemap.Map()
m.set_center(-78.405278, 35.647222, 16)

dataset = ee.ImageCollection('NASA/HLS/HLSL30/v002').filterDate('2020-01-21', '2020-02-20').filter(ee.Filter.lt('CLOUD_COVERAGE',70))
dataset = dataset.map(apply_scale_factors)
m.add_layer(dataset.mean(), visualization, 'True Color (321)')
m

Is there a way to export images from this image collection at this location over many dates (from 2014 to 2024, perhaps)?

And is there a way to download them directly to your machine?

I tried this, but it uses a deprecated geometry tool

roi = ee.Geometry.Rectangle([-78.41, 35.65, -78.40, 35.64])
collection = (ee.ImageCollection('NASA/HLS/HLSL30/v002')
                .filterDate('2020-01-01', '2020-03-01')
                .filter(ee.Filter.lt('CLOUD_COVERAGE', 70))
                .filterBounds(roi))
# Export the ImageCollection
tasks = geetools.batch.Export.imagecollection.toDrive(
    collection=collection,
    folder='gee_images',
    region=roi,
    namePattern='{id}',
    scale=30,
    dataType='uint32',
    verbose=True,
    maxPixels=int(1e13)
)

returns error

/usr/local/lib/python3.10/dist-packages/geetools/tools/_deprecated_geometry.py in getRegion(eeobject, bounds, error)
     12 def getRegion(eeobject, bounds=False, error=1):
     13     """Gets the region of a given geometry to use in exporting tasks."""
---> 14     return eeobject.geometry()
     15 
     16 

AttributeError: 'Geometry' object has no attribute 'geometry'