Geographic Information Systems Asked by SteveAKopias on April 6, 2021
I’m trying to get the max value of a generated cumulativeCost Image in Earth Engine, via the Python API. I thought reduceRegion
should work, but it dies.
My relevant code:
malawi = ee.FeatureCollection('USDOS/LSIB/2017').filter(ee.Filter.inList('COUNTRY_NA', ["Malawi"]))
malawi_geometry = malawi.geometry()
nl_raw = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS')
nl_three_newest = nl_raw.sort('system:time_start', False).limit(3)
nl_stable_lights_only = nl_three_newest.select('stable_lights')
nl_quality_mosaic = nl_stable_lights_only.qualityMosaic('stable_lights')
nl_clipped_to_malawi = nl_quality_mosaic.clip(malawi_geometry)
has_light_at_all = nl_clipped.gte(1)
no_light_at_all = nl_clipped.lt(1)
has_light_at_all_mask = ee.Image().toByte().paint(has_light_at_all.geometry(), 1).updateMask(has_light_at_all)
max_dist = 70 * 1000
dist_to_light_at_all_from_light_mask = no_light_at_all.cumulativeCost(has_light_at_all_mask, max_dist)
dist_to_light_at_all_from_light_mask_max = dist_to_light_at_all_from_light_mask.reduceRegion(
reducer=ee.Reducer.max(),
geometry=malawi_geometry,
scale=30,
maxPixels=10**9
)
print(dist_to_light_at_all_from_light_mask_max.getInfo())
You can check the whole code with comments and displayed maps in Python here:
https://colab.research.google.com/drive/1z_3_a1UfVwEy1jJEd2Ms1xxw-76HXBPn?usp=sharing
Or in the web editor in Javascript:
https://code.earthengine.google.com/?scriptPath=users%2Fattilastevekopias%2Fdebug%3Anight-lights-debug
The problem is that the final print dies with this message:
HttpError 400 when requesting https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/value:compute?prettyPrint=false&alt=json returned "EEException: Object too large (133984872 bytes)."
What I’ve tried:
reduceRegion
function with other images, like the nl_quality_mosaic_max
or the nl_clipped_to_malawi_max
(the results of the previous steps before the cumulativeCost) and with everything else it works as it should: the print(*.getInfo())
gives back a dictionary like "{'stable_lights': 63}"
.dist_to_light_at_all_from_light_mask_max
object like size, type, keys, tried to serialize it and print a slice of that etc etc, but nothing works, I get similar errors, or sometimes just a timeout.So what I’m hoping somebody will be able to help me with:
The motivation for this that I will generate many similar images in different areas, with different light-intensity cutoffs (or even other types of objects from other ImageCollections) etc, ergo the "maximum distance any point can have in the selected region from a lightsource at least this intense" value will range from hundred to the hundred-thousands meters. And of course I want to display these maps on a colorscale, but to do that I need to know the range it has to cover. And also this exact number is a useful information I need to store for later use.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP