Google Earth Engine Task Batch – How to Fix DownloadTo Not Downloading Images

google-earth-engine

I'm running a piece of code that get some satellite images, clip them, and then save the clipped area to a folder in my Google Drive.
The code runs with no errors (after debugging), but when I go and check the downloading progress in my Google Drive… there's nothing.
Not a single (out of 12) .tiff file downloaded.

This is the code:

This is how satellite images are loaded/referenced into the ee_var dictionary (Please don't mind the 'if' statement, they always return True)

  if variables == None:
    variables = ['srtm','slope','aspect','hillshade','flowdir','flowacc','organic','organic','density','rain','etp','ndvi_mean','landcover']
    ee_var = {}

    # 1. ee.Image relacionadas a un key
    #    ejemplo: srtm---> WWF/HydroSHEDS/03CONDEM
    if 'srtm' in variables:
      srtm = ee.Image("WWF/HydroSHEDS/03CONDEM")
      ee_var['srtm'] = srtm

    if 'slope' in variables:
      slope = ee.Terrain.slope(srtm)
      ee_var['slope'] = slope    

    if 'aspect' in variables:
      aspect = ee.Terrain.aspect(srtm)
      ee_var['aspect'] = aspect

Then this is how the satellite images (AOI clipped) should be downloaded:

  for key, value in ee_var.items():
       to_download = ee.Image(value).clip(geom)
       task = ee.batch.Export.image.toDrive(
           image=to_download,
           description=prefix+key,
           folder=folder,
           scale=scale,
           region=geom)
       task.start()

Since I have 0 downloads from GEE, I've checked the EarthEngineTaskManager, and I have the following error for every piece of imagery I was trying to download:

"
Error: GeometryConstructors.LineString, argument 'coordinates': Invalid type. Expected type: List. Actual type: Feature. (Error code: 3)
"

A piece of could that could be relevant in solving this issue could be how I define the AOI, using geojson. Here's the heading of the geojson, with the first three coordinates (there are more, but are irrelevant to the topic):

Samaipata = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -63.91021728515624,
              -18.20848019603987
            ],
            [
              -63.77357482910156,
              -18.20848019603987
            ],
         ...

Any ideas on what could be wrong?

I found the problem. I was calling my def function with the wrong type of argument.
This was the wrong code:

spatial_dataset(ee_samaipata, 'Smpta_', 'DataSatImg', 30)

And this is the right coding:

spatial_dataset(ee_samaipata.geometry(), 'Smpta_', 'DataSatImg', 30)

ee_Samaipata is an AOI with lat,lon coordinates in geojson.

Best Answer

So I found the error: Was in the way I was calling my function. My function needed a geometry object, and I was sending a different one: Wrong function call:

spatial_dataset(ee_samaipata, 'Smpta_', 'DataSatImg', 30)

Correct function call:

spatial_dataset(ee_samaipata.geometry(), 'Smpta_', 'DataSatImg', 30)