I am trying to process a Tanzania shapefile downloaded from GADM Global Administrative Areas.

    # im -> {Image} ee.Image({...})
    # self.geom_coll -> {FeatureCollection} ee.FeatureCollection({...}). containing 
    # 3000 features.
    # spacereducer() -> ee.Reducer.mean
    # self.scale -> 10 #Changing this value to small number gives error

    feats = im.reduceRegions(self.geom_coll, spacereducer(), self.scale)
    flist = getInfo_werrorcontrol(feats,


def getInfo_werrorcontrol(featureCollection, errorcontrolon=True):
    Wrapper to add error control to GEE evaluations.

    For large computations GEE sometimes times out and needs to be
    restarted. This does so in a controlled manner with out 
    interrrupting the program flow.
    if errorcontrolon:
        while True:
                with timeout.timeout(10*60):
                    return featureCollection.getInfo() # In this line I am getting exception.
            except NameError:
                exc_type, exc_value, exc_traceback = sys.exc_info()
                lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
                print ''.join('!! ' + line for line in lines)
                print 'attempts: '+str(i)
                if i > 20:
                    raise ValueError('to many attempts') 
                elif i > 10:
                    print 'waiting 2 minutes'
        return featureCollection.getInfo()

Exception:- Changing self.scale to 10 gives me following error for line: featureCollection.getInfo()

ee.ee_exception.EEException: Server returned HTTP code: 413

Changing self.scale to 1000 gives me following error:

ee.ee_exception.EEException: Computation timed out

What is the correct way to process shapefile with the larger region?

Your Answer

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

Browse other questions tagged or ask your own question.