0

When I import my image into ArcGIS Desktop I get a black border around the region that didn't exist before in Google Earth Engine (GEE).

How can I prevent GEE from doing this when I export an image?

enter image description here

7
  • Set whatever value the black is to the color white. Border gone.
    – Jon
    Commented Oct 9, 2018 at 19:25
  • @Jon thanks for the answer, but the issue with that is the border isn't noData, it's been assigned to class 0. It causes issues with my analysis. I need to find a way to prevent GEE from exporting the border all-together. Commented Oct 9, 2018 at 19:32
  • Export the image as a float and the masked pixels should be nodata. Apparently that's not an option for int-type exports.
    – Jon
    Commented Oct 9, 2018 at 19:48
  • Alternatively set the metadata of the Geotiff accordingly NoData Value = 0 and your GIS software will then interpret all 0 value pixels as No Data.
    – Kersten
    Commented Oct 10, 2018 at 7:50
  • @Kersten that's basically what I said to do within GIS, but apparently there are legitimate zero values within the non-masked region :/
    – Jon
    Commented Oct 10, 2018 at 13:55

1 Answer 1

1

I'm not sure why GEE adds a black border to exported images, I think it's something to do with the re-orienting the image to the new projection system and cannot be changed. This isn't an issue if you're exporting a satellite image raster, as it sets the border pixel values to class 0 and this doesn't interfere with the pixels in the rest of the image.

It's a bit of a pain when exporting a classified image that contains useful pixels that are classified as zero as this messes with the analysis. Anyway, I managed to figure it out with a simple .remap code. I just reassigned the values from class 0 onwards to the integer above, thus leaving class 0 free for noData pixels. Here is the code:

// Classified image with 5 classes (from cluster analysis)
var classified_image = cluster.cluster(clusterer);

// remap values in class to integer above so class 0 becomes free for noData pixels   
var remap = ee.Image(classified_image)
 .remap([0,1,2,3,4], [1,2,3,4,5]);

Export.image.toDrive({...

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.