I try to code Mosaicking a Image Collection by Date (day) in Google Earth Engine this issue with Python.

#Load Sentinel 1 and filter data
def load_dataset(ImageCollection_ID,begin,end,aoi):
    ic = ee.ImageCollection(ImageCollection_ID).filterDate(begin,end).filterBounds(aoi)
    return ic

def filter_sentinel1(ImageCollection,polarisation,instrumentMode,resolution):
    ic = ImageCollection.filter(ee.Filter.listContains('transmitterReceiverPolarisation',polarisation)).filter(ee.Filter.eq('instrumentMode',instrumentMode)).filterMetadata('resolution_meters','equals', resolution)
    return ic

def seperate_look_angels(ImageCollection,polarisation):
    Ascending = ImageCollection.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING')).select(polarisation)
    Descending = ImageCollection.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING')).select(polarisation)
    return Ascending,Descending

def get_properties(ImageCollection):
    features = ImageCollection.getInfo()['features']
    dict_list = []
    for f in features:
        prop = f['properties']
    df = pd.DataFrame.from_records(dict_list).drop(['system:footprint','transmitterReceiverPolarisation'],axis=1)
    #Pandas Series of unique distinc values in df
    unique = df.nunique()
    im_id_list = [item.get('id') for item in ImageCollection.getInfo().get('features')]
    date_list = [datetime.datetime.strptime(x[35:43],'%Y%m%d') for x in im_id_list]
    #property_names = list(df.columns.values) 
    return unique, im_id_list, date_list

def make_mosaic(date):
    date = ee.Date(date['value'])
    filterCollection = VV_Ascending.filterDate(date, date.advance(1,'day'))
    image = ee.Image(filterCollection.mosaic()).copyProperties(filterCollection.first(),["system:time_start"])
    return image

#Time of interest
begin = ee.Date.fromYMD(2016,1,1)
end = ee.Date.fromYMD(2016,3,1)
date_range = end.difference(begin, 'day')

#Source dataset
ried_225_222 = ee.FeatureCollection('users/tillmueller1990/ried_225_222')
sentinel1 = load_dataset('COPERNICUS/S1_GRD',begin,end,ried_225_222)
#Filter dataset for High resolution and Vertical transmitt vertical receive
sentinel1_VV = filter_sentinel1(sentinel1,'VV','IW',10)
#Filter for different look angles
VV_Ascending,VV_Descending = seperate_look_angels(sentinel1_VV,'VV')

#Get list of ids,dates and unique count of prop
unique, im_id_list, date_list = get_properties(VV_Ascending)
date_list = ee.List([ee.Date(x) for x in date_list])
newList = ee.List([])

for date in date_list.getInfo():
    mosaic = ee.Image(make_mosaic(date))
newcol = ee.ImageCollection(newList)

the function make_mosaic(date) return for every date a image. The output of print(mosaic.getInfo()) is

{'type': 'Image', 'bands': [{'id': 'VV', 'data_type': {'type': 'PixelType', 'precision': 'double'}, 'crs': 'EPSG:4326', 'crs_transform': [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]}], 'properties': {'system:time_start': 1452618462260.0}}

I try to add this image to an empty ee.List([]) named newList to call later ee.ImageCollection(newList) but the newList remains empty. Why i cant add the images to the list with newList.add(mosaic)?

1 Answer 1


The objects (Most of them, if not all) in GEE are immutable so you'll have to do

    newList = newList.add(mosaic)

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.