0

I run randomforest classification in gee API. My script below:

label = 'class'
bands = ['VV', 'VH']
# Load training data from FeatureCollections
training_14Aug_shp = ee.FeatureCollection('projects/training_14Aug22')
training_24Feb_shp = ee.FeatureCollection('projects/training_24Feb22')
training_10Jan_shp = ee.FeatureCollection('projects/training_10Jan22_S1')

# Sample training data from refinedLee images
training_14Aug = s1_Aug_refinedLee.select(bands).sampleRegions(
    collection=training_14Aug_shp,
    properties=[label],
    scale=10,
    tileScale=16) # increase tilescale to overcome the issue memory limit

training_24Feb = s1_Feb_refinedLee.select(bands).sampleRegions(
    collection=training_24Feb_shp,
    properties=[label],
    scale=10,
    tileScale=16)

training_10Jan = s1_Jan_refinedLee.select(bands).sampleRegions(
    collection=training_10Jan_shp,
    properties=[label],
    scale=10,
    tileScale=16)

# Combine training data
training14Aug_10Jan = training_14Aug.merge(training_10Jan)
training14Aug_24Feb_10Jan = training14Aug_10Jan.merge(training_24Feb)

# Train a Random Forest classifier with default parameters
trained = ee.Classifier.smileRandomForest(1000).train(
    features=training14Aug_24Feb_10Jan,
    classProperty=label,
    inputProperties=bands)

I have error as below:

HttpError                                 Traceback (most recent call last)
File ~\.conda\envs\Deep_learning_outside\lib\site-packages\ee\data.py:379, in _execute_cloud_call(call, num_retries)
    378 try:
--> 379   return call.execute(num_retries=num_retries)
    380 except googleapiclient.errors.HttpError as e:

File ~\.conda\envs\Deep_learning_outside\lib\site-packages\googleapiclient\_helpers.py:130, in positional.<locals>.positional_decorator.<locals>.positional_wrapper(*args, **kwargs)
    129         logger.warning(message)
--> 130 return wrapped(*args, **kwargs)

File ~\.conda\envs\Deep_learning_outside\lib\site-packages\googleapiclient\http.py:938, in HttpRequest.execute(self, http, num_retries)
    937 if resp.status >= 300:
--> 938     raise HttpError(resp, content, uri=self.uri)
    939 return self.postproc(resp, content)

HttpError: <HttpError 400 when requesting https://earthengine.googleapis.com/v1/projects/earthengine-legacy/value:compute?prettyPrint=false&alt=json returned "Computed value is too large.". Details: "Computed value is too large.">

1 Answer 1

2

You can figure out which of the operations is too big by trying to print the size of each of the point samples, and the classifier.explain(), and seeing which one barfs first.

Most likely, you are sampling too many points, probably because your regions have a lot of pixel in them. Use something like stratifiedSample to select a subset of points from the regions, if those are indeed what's too large.

If it's the classifier, then 1000 trees is just too many for the data you have. Use less nodes.

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.