Returns a series of brightness over time for the polygon.
(polygon_id)
| 158 | |
| 159 | |
| 160 | def 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 | |
| 185 | def GetFeature(polygon_id): |
no test coverage detected