1

I've wrote below code for landsat and sentinel mosaicing, however I don't know how can I resample sentinel-2 pixel size to landsat-8 data? Could anyone guide me please?

code link: https://code.earthengine.google.com/e65292e8cda25e846d2a9889a91a3b45

Map.centerObject(table)

var sen2mosaic = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2018-01-01','2019-01-01')
.filterBounds(table)
.map(function(img){
  var bands = img.select('B[3-4]','B8')
  .multiply(0.0001).clip(table)
   return bands
  .copyProperties(img,['system:time_start','system:time_end'])

})
.min();

Map.addLayer(sen2mosaic,[],'sen2mosaic',false)


var lan8mosaic = ee.ImageCollection('LANDSAT/LC08/C01/T1')
.filterDate('2018-01-01','2019-01-01')
.filterBounds(table)
.map(function(img){
  var bands = img.select('B[3-5]')
  .multiply(0.0001).clip(table)
  return bands
  .copyProperties(img,['system:time_start','system:time_end'])

})
.min();

Map.addLayer(lan8mosaic,[],'lan8mosaic',false)

1 Answer 1

2

According to the resampling docs on the Earth Engine Guides, you can reduce resolution using the ee.Image.reproject() function. Check out the link for more on what's going on under the hood, and make note of the warnings they list there.

var myCounty = ee.FeatureCollection('TIGER/2016/Counties')
  .filter(ee.Filter.eq('NAME', 'Kalawao'));
var table = myCounty;

Map.centerObject(table);

var sen2mosaic = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2018-01-01','2019-01-01')
.filterBounds(table)
.map(function(img){
  var bands = img.select('B[3-4]','B8')
  .multiply(0.0001).clip(table);
   return bands
  .copyProperties(img,['system:time_start','system:time_end']);

})
.min();
print("sen2mosaic", sen2mosaic);


var lan8mosaic = ee.ImageCollection('LANDSAT/LC08/C01/T1')
.filterDate('2018-01-01','2019-01-01')
.filterBounds(table)
.map(function(img){
  var bands = img.select('B[3-5]')
  .multiply(0.0001).clip(table);
  return bands
  .copyProperties(img,['system:time_start','system:time_end']);

})
.min();
print("lan8mosaic", lan8mosaic);

// Using code from earthEngine docs:
// Get LS8 projection
var ls8Projection = lan8mosaic.projection();
// Resample Sentinel data
var sentinelMean = sen2mosaic
    .reproject({
      crs: ls8Projection,
      scale: 30
    });

print("sentinelMean",sentinelMean);


// Display the aggregated, reprojected data.
Map.addLayer(lan8mosaic.visualize({bands:["B3","B4","B5"], min:0, max:1}),[],'lan8 NDVI');
Map.addLayer(sen2mosaic.normalizedDifference({bandNames:["B8","B4"]}), {min:0, max:1},'sen2 NDVI');
Map.addLayer(sentinelMean.normalizedDifference({bandNames:["B8","B4"]}), {min:0, max:1}, 'Sentinel NDVI at LS8 scale');

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.