I am trying to find the distance to nearest mature forest pixel in google earth engine. If I run this code and visualize, it looks perfect:
data_folder = "projects/amazon-forest-regrowth/assets"
mature_biomass_1k = ee.Image(f"{data_folder}/mature_biomass_1km_100m")
age_agbd = ee.Image(f"{data_folder}/age_agbd")
distance = mature_biomass_1k.fastDistanceTransform().sqrt() \
.multiply(ee.Image.pixelArea().sqrt()).rename("distance") \
.updateMask(age_agbd.select("age")).float()
map.addLayer(distance, {"min": 0, "max": 400000, "palette":["green", "yellow"]}, "distance")
However, after exporting, I see there is a strange "pixelated" pattern in the exported raster that does not look the same from what I previously mapped:
# Create the export task
task = ee.batch.Export.image.toAsset(
image=distance,
description="distance",
assetId="projects/amazon-forest-regrowth/assets/distance",
region = distance.geometry(),
crs="EPSG:4326",
maxPixels=5e10
)
# # Start the export task
task.start()
There is a large discrepancy in the visualized vs the exported data, and the exported data shows a very stark "step" in the estimated distance values.
I imagine this may have something to do with how google earth engine evaluates data to export it, but how can I fix this?
Edit: I tried this with lower scales (100m). When running the script with larger resolutions (500m +) the problem disappears, which leads me to believe it is something related to computational power. However, I do need the distances to be known at a higher resolution than 500m, so I would like to learn how to get this result for high resolutions