Exporting collection to Cloud Storage

toCloudStorage(collection, bucket="opencrops", folder=None, namePattern='{id}', scale=30, dataType="float", region=None, datePattern=None):

Export an image clipped by features (Polygons). You can use the same arguments as the original function ee.batch.export.image.toDrive

Parameters

  • collection: image collection
  • bucket: GCS bucket
  • folder: same as ee.Export
  • name: name of the resulting image. If None uses image's ID
  • scale: same as ee.Export. Default to 1000
  • dataType: as downloaded images must have the same data type in all bands, you have to set it here. Can be one of: "float", "double", "int", "Uint8", "Int8" or a casting function like ee.Image.toFloat
  • region: geometry to clip export
  • kwargs: keyword arguments that will be passed to ee.batch.export.image.toCloudStorage

Return a list of all tasks (for further processing/checking)


In [1]:
import ee
import sys
sys.path.append("../..")
ee.Initialize()
from geetools import batch

Get an Image Collection


In [2]:
p1 = ee.Geometry.Point([-71,-42])
feat1 = ee.Feature(p1.buffer(1000), {'site': 1})
fc = ee.FeatureCollection([feat1])
collection = ee.ImageCollection('COPERNICUS/S2').filterBounds(fc.geometry()).filterDate("2015-01-01","2015-12-01")

In [3]:
# please ensure that you have a default project enabled
# and change this bucket with a bucket you have write access
BUCKET = "opencrops"

batch.imagecollection.toCloudStorage(collection, bucket=BUCKET, folder="geetools", scale=30, verbose=True)


adding task 20150825T143316_20150825T144048_T19GCP to list
adding task 20150825T143316_20161001T010844_T19GCP to list
adding task 20150825T144048_20160417T022845_T19GCP to list
adding task 20151123T142942_20170221T180430_T19GCP to list

In [4]:
# check the storage bucket via the gsutil tool
!gsutil ls gs://opencrops/geetools


gs://opencrops/geetools/20150825T143316_20150825T144048_T19GCP.tif
gs://opencrops/geetools/20150825T143316_20161001T010844_T19GCP.tif
gs://opencrops/geetools/20150825T144048_20160417T022845_T19GCP.tif
gs://opencrops/geetools/20151123T142942_20170221T180430_T19GCP.tif