MCPcopy
hub / github.com/google/earthengine-api / ComputePolygonTimeSeries

Function ComputePolygonTimeSeries

demos/trendy-lights/server.py:160–182  ·  view source on GitHub ↗

Returns a series of brightness over time for the polygon.

(polygon_id)

Source from the content-addressed store, hash-verified

158
159
160def ComputePolygonTimeSeries(polygon_id):
161 """Returns a series of brightness over time for the polygon."""
162 collection = ee.ImageCollection(IMAGE_COLLECTION_ID)
163 collection = collection.select('stable_lights').sort('system:time_start')
164 feature = GetFeature(polygon_id)
165
166 # Compute the mean brightness in the region in each image.
167 def ComputeMean(img):
168 reduction = img.reduceRegion(
169 ee.Reducer.mean(), feature.geometry(), REDUCTION_SCALE_METERS)
170 return ee.Feature(None, {
171 'stable_lights': reduction.get('stable_lights'),
172 'system:time_start': img.get('system:time_start')
173 })
174 chart_data = collection.map(ComputeMean).getInfo()
175
176 # Extract the results as a list of lists.
177 def ExtractMean(feature):
178 return [
179 feature['properties']['system:time_start'],
180 feature['properties']['stable_lights']
181 ]
182 return map(ExtractMean, chart_data['features'])
183
184
185def GetFeature(polygon_id):

Callers 1

GetPolygonTimeSeriesFunction · 0.85

Calls 6

selectMethod · 0.95
GetFeatureFunction · 0.85
mapClass · 0.85
sortMethod · 0.45
getInfoMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected