0

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.

5
  • 1
    Batch tasks can fail for many reasons, including code errors that cannot be detected until the task starts. Consult the Earth Engine task manager to see the status of your task. Once you know what happened, please edit your question to give more details such as the error message if any. We may also need to see the rest of your code.
    – Kevin Reid
    Commented Aug 20, 2022 at 23:41
  • Kevin, thanks in advance for your help/advice. I've edited my question and added the requested information. Could you please check it again? Thanks.
    – Delonix R.
    Commented Aug 26, 2022 at 23:25
  • Yes, that's more information, but not enough to definitively identify the problem. You've posted some fragments but without the connections between them. It will be helpful if you can come up with a program that is short enough to post in its entirety that demonstrates the problem when run. That is, take your code, remove parts that aren't necessary to get the same error, test it to confirm it does, and iterate until you have something you can't reduce farther. This may sound like a lot of work, but it can be very helpful to us and to you (you might discover the problem yourself!)
    – Kevin Reid
    Commented Aug 27, 2022 at 0:14
  • Kevin, thanks a lot for your help and interest in helping me (and others that might read this thread later). I've solve the problem. As usual, some parameters were missing and/or missplaced. I was calling a function with the wrong type of parameters. I'll explain in the code. Thanks again!
    – Delonix R.
    Commented Aug 27, 2022 at 0:50
  • Great to hear you figured it out! If you don't mind, could you take the explanation you wrote and put it in the answer box? It's completely fine to post an answer to your own question, and it helps keep things organized on the site (indicating that this problem has been solved).
    – Kevin Reid
    Commented Aug 27, 2022 at 4:06

1 Answer 1

0

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)

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.