When I export the big images in Google Drive, Google Earth Engine is supposed to tile them automatically but they don't even appear in my drive.

What is happening?

Here is my code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
Created on Tue Sep 28 14:19:15 2021

@author: karas

import geemap
import geetools
import os
import argparse
from cloud_mask import *
import ee

# Download filtered data and unite them with cloud data
def filtering(dataset, sdate, edate, aoi, cloud):
    # # Area of Interest
    # aoi = ee.Geometry.Rectangle([float(aoi[0]), float(aoi[1]), float(aoi[2]), float(aoi[3])])
    aoi = ee.Geometry.Point(float(aoi[0]), float(aoi[1]))
    # Getting the dataset
    dataset = ee.ImageCollection(dataset)\
        .filterDate(sdate, edate)\
        .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', cloud))\

    # Import and filter cloud masks for corresponding images
    s2_cloudless_col = (ee.ImageCollection('COPERNICUS/S2_CLOUD_PROBABILITY')
        .filterDate(sdate, edate))
    # Join the filtered s2cloudless collection to the SR collection by the 'system:index' property.
    return ee.ImageCollection(ee.Join.saveFirst('s2cloudless').apply(**{
        'primary': dataset,
        'secondary': s2_cloudless_col,
        'condition': ee.Filter.equals(**{
            'leftField': 'system:index',
            'rightField': 'system:index'

# Initialize the library.

# # Creating the arguments 
# parser = argparse.ArgumentParser(description = 'Downloading parameters')
# parser.add_argument('--dataset', type = str,
#                     help = 'Dataset to be used')
# parser.add_argument('--sdate', type = str,
#                     help = 'Start date')
# parser.add_argument('--edate', type = str,
#                     help = 'End date')
# parser.add_argument('--aoi', nargs = '+',
#                     help = 'Area of Interest with geographical coordinates')
# parser.add_argument('--out_path', type = str,
#                     help = 'Path to save images')
# parser.add_argument('--cloud_cov', type = int,
#                     help = 'Cloud coverage')
# args = parser.parse_args()

# Creating a list of bands
bands = ['B2', 'B3', 'B4', 'B8', 'SCL']

# Getting the dataset
# dataset = filtering(args.dataset,
#                     args.sdate,
#                     args.edate,
#                     args.aoi,
#                     # rectROI,
#                     args.cloud_cov).select(bands)

dataset = filtering('COPERNICUS/S2_SR',
                    [23, 40],

# Add cloud and cloud shadow component bands to each image and then apply the mask to each image
# dataset_cloudless = (dataset.map(add_cld_shdw_mask)
#                               .map(apply_cld_shdw_mask)
#                               )

region = ee.Geometry.Polygon(dataset.first().geometry().bounds().getInfo()['coordinates'])

task = ee.batch.Export.image.toDrive(dataset.first(),\
                              description = '256x256 tile',\
                              scale = 30,\
                              region = region.getInfo()['coordinates'],\
                              fileFormat = 'GeoTIFF',
                              folder = 'x',

You control the tiling with the fileDimensions property in Export.image.toDrive(). According to the docs:

The dimensions in pixels of each image file, if the image is too large to fit in a single file. May specify a single number to indicate a square shape, or an array of two dimensions to indicate (width,height). Note that the image will still be clipped to the overall image dimensions. Must be a multiple of shardSize.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.