0

I have some manipulation in Google Earth Engine, for example:

// Load a cloudy Landsat scene and display it.
var cloudy_scene = ee.Image('LANDSAT/LC8_L1T_TOA/LC80440342014269LGN00');
Map.centerObject(cloudy_scene);
Map.addLayer(cloudy_scene, {bands: ['B4', 'B3', 'B2'], max: 0.4}, 'TOA', false);

// Add a cloud score band.  It is automatically called 'cloud'.
var scored = ee.Algorithms.Landsat.simpleCloudScore(cloudy_scene);

// Create a mask from the cloud score and combine it with the image mask.
var mask = scored.select(['cloud']).lte(20);

// Apply the mask to the image.
var masked = cloudy_scene.updateMask(mask);

And now I want to export result (masked) to google drive using method Export.image.toDrive, but I don't known how to specify parameter region to meet the same as original image LANDSAT/LC8_L1T_TOA/LC80440342014269LGN00 is.

Please help me construct this region.

www
  • 38,575
  • 12
  • 48
  • 84

1 Answers1

1

I think that's what you're looking for:

Export.image.toDrive({

  image:masked.select('B3'),
  description: 'Masked_Landsat_Image',
  region:masked.geometry(),
  scale:mask.projection().nominalScale().getInfo()

})

In this case I'm using the image's footprint ( with image.geometry() ) to define my export region.

Note that I'm using the function mask.projection().nominalScale().getInfo() to derive the scale (resolution) of your export. This makes sure I'm using the native resolution of the image (in this case 30m). You need to add getInfo to the function to actually retrieves the integer from the server. You could also just specify 30 or any other desired resolution in meters.

HTH


Edit:

Just a visual aid to what I've written in the comment below:

3 Images:

  1. Top left corner of original LS image (downloaded from EarthExplorer) - Red indicates NoData

Image 1

  1. LS image from GEE on top of original image (GEE image has redish pixels) - You can clearly see that there's still the NoData part of the original image which is missing in the GEE version. The thing I would be concerned about is that the pixels don't line up nicely.

Image 2

  1. The top right corner of both images: Here you can see how far the 2 images are apart

enter image description here

Val
  • 6,585
  • 5
  • 22
  • 52
  • Thank You for suggestion. I've try to extract B3 as in your suggestion, and result image is very close to original but it still have different dimension (7647x7803 instead of 7671x7811). ! – Nguyen Ba Thi May 05 '17 at 01:52
  • I would't worry about this small difference. The `.geometry()` function gives you the real footprint of the image, it's all google earth engine has. The difference to what's stated in the metadata are due to small fringes of `NoData` in the original dataset. So when you download the image from GEE, you might have slightly smaller dimensions, but the "real" image has the same size. – Val May 05 '17 at 08:28
  • Again, Thank You for explanation! I think, I should accept this real of GEE. – Nguyen Ba Thi May 05 '17 at 09:28
  • If you're happy with my explanation, please consider accepting my answer. Thank you. – Val May 05 '17 at 09:56