question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

batch.imagecollection.toCloudStorage does not upload all files

See original GitHub issue

Thank you for making this functionality available.

I’m been trying to export some images on my google cloud storage, but am running into trouble. Below is an example of my run when I try to upload 9 images

BUCKET = "detect_proto"
imageExportFormatOptions = {
      'patchDimensions': [75, 75],  
      'maxFileSize': 100000000,    
      'compressed': True
    }
batch.imagecollection.toCloudStorage(newImgCol, bucket=BUCKET, folder="geetools", scale=10, 
                                     fileFormat = 'TFRecord', verbose=True,
                                     formatOptions = imageExportFormatOptions)

This will yield the following output

adding task 0 to list
adding task 1 to list
adding task 2 to list
adding task 3 to list
adding task 4 to list
adding task 5 to list
adding task 6 to list
adding task 7 to list
adding task 8 to list

But when I check my cloud storage, only 1 file has been uploaded

gsutil ls gs://detect_proto/geetools
gs://detect_proto/geetools/0.json
gs://detect_proto/geetools/0.tfrecord.gz

I’m a bit confused why only 1 file has been uploaded, any thoughts on how to investigate this would be greatly appreciated. CC @MarcCoru @fitoprincipe

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
csong21commented, Jun 28, 2020

I updated my code and this seems to work. The only change that enabled it to work is that I moved the imageExportFormatOptions within the for loop.

for x, y in neighbors:

    imgs = ee.ImageCollection('COPERNICUS/S2').filterDate(str(last_month), str(today_date)).filterBounds(ee.Geometry.Point([lon, lat])).map(maskS2clouds)
    # Get the latest image for the bounding area
    lastimg = imgs.limit(1, 'system:time_start', False).first()
    # Preprocess the image the same way as the training data
    lastimg = lastimg.select(bands).multiply(0.0001)
    # Starting from the same export buffer as the training data
    xmin, ymin, xmax, ymax = [x - 0.0025, y - 0.005, x + 0.006, y + 0.0025]
    buffer_rect = ee.Geometry.Rectangle([xmin, ymin, xmax, ymax])
    lastimg_clip = lastimg.clip(buffer_rect)

    imageFilePrefix= 'ProjectID_' + str(project_id) + '_window' + str(w)

    imageExportFormatOptions = {
      'patchDimensions': [75, 75],  
      'maxFileSize': 100000000,    
      'compressed': True
    }


    imageTask = ee.batch.Export.image.toCloudStorage(
          image = lastimg_clip,
          description = 'ExportLastImageClip',
          fileNamePrefix = imageFilePrefix,
          bucket = outputBucket,
          scale = 10,
          fileFormat = 'TFRecord',
          region = buffer_rect,
          formatOptions = imageExportFormatOptions
        )
    imageTask.start()

    print('\n   Exporting window %i to Google Cloud Storage' % w)
          
    while imageTask.active():
      print('\n       Polling for task (id: {}).'.format(imageTask.id))
      time.sleep(5)

    print(imageTask.status()['state'])

    w+=1```
0reactions
csong21commented, Jun 28, 2020

Thanks @MarcCoru for your feedback!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export.image.toCloudStorage | Google Earth Engine
Argument Type Details image Image The image to export. bucket String, optional The Cloud Storage destination bucket. scale Number, optional Resolution in meters per pixel. Defaults...
Read more >
No image exported from GEE ImageCollection to Cloud Storage
My workstation runs Ubuntu 20.04. The code below does not return any error, but the 212 images in collection are not exported either....
Read more >
gee_tools/imagecollection.py at master - geetools - GitHub
Upload all images from one collection to Google Drive. You can use. the same arguments as the original function. ee.batch.export.image.toDrive.
Read more >
Google Earth Engine Batch Upload Images with Metadata into ...
Step 2: Upload the files with metadata (I can not make it in Colab, even local Jupyter ... getmeta Generates generalized metadata for...
Read more >
Upload files with Cloud Storage on Web - Firebase
Be sure to restrict access to your Cloud Storage bucket again when you set up Authentication. Upload Files. To upload a file to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found