download of specific bands by clipping to a region fails
ysubash opened this issue · comments
Issue : Downloading the clipped tile by passing the region fails with the below error message
User limit exceeded, decrease the max_tile_size or max_tile_dim limit
When I set the region to None there is no issue.
Below is the code i use to download the data
gee_img = gd.MaskedImage.from_id(fc_df["ID")
download_bands_from_gee(gee_img, geom, band_names=['B4','B8','SCL'])
def download_all_bands_from_gee(collection,geom=None, ofilename=None):
if ofilename is None:
ofilename = pathlib.Path(collection.id).stem + ".tif"
collection.download(ofilename, region=geom,overwrite = True)
I search and get the list of tiles and loop through the tiles.
def download_bands_from_gee(collection, geom, band_names=0):
coll = collection.ee_image
img = coll.select(band_names)
info = img.getInfo()
band_name = info["bands"][0]["id"]
proj_target = img.select(0).projection()
crs_target = proj_target.getInfo()['crs']
ofilename = pathlib.Path(collection.id).stem + "_" + band_name + ".tif"
collection_new = gd.MaskedImage(img)
download_all_bands_from_gee(collection_new, None, ofilename)
Hello. What are the values of fc_df["ID"]
and geom
?
geom = {'type': 'Polygon', 'coordinates': [[[4.275583981624501, 51.20401018220516], [4.275583981624501, 51.7412925316889], [3.359677872973738, 51.7412925316889], [3.359677872973738, 51.20401018220516], [4.275583981624501, 51.20401018220516]]]}
and thefc_df["ID"]
are
COPERNICUS/S2_SR/20191130T110319_20191130T110622_T31UET
COPERNICUS/S2_SR/20191130T110319_20191130T110622_T31UES
COPERNICUS/S2_SR/20191202T105421_20191202T105436_T31UET
COPERNICUS/S2_SR/20191202T105421_20191202T105436_T31UES
looped through
MaskedImage
includes a computed mask band. GEE is running out of memory when computing this in tiles outside of the image footprint. You can work around it in one of two ways:
- Make sure the download region lies inside the image footprint e.g.
import ee
...
region = ee.Geometry(geom).intersection(collection.footprint)
collection.download(ofilename, region=region, overwrite=True)
- Specify the
max_tile_size
parameter in the call toMaskedImage.download()
.max_tile_size=8
works for me.