0

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")

Perfect map

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()

map2

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?

map3

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

1 Answer 1

0

You didn't set a scale in the Export. You also haven't set a neighborhood on the fastDistanceTransform() call, which means you're only getting a default neighborhood of 256 pixels, which at 100m scale means anything farther than 25km is capped.

1
  • My bad - I ran this script so many times I did not specify the scales in my question. I have this issue when I try to run with scale = 100. Scale = 500 works just fine, which leads me to believe it is something related to computational power and how GEE allots it Commented Jul 22 at 15:39

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.