0

I would like to run a spatial regression to refine the spatial resolution of Sentinel-2 20 m bands by using the 10 m 8A band. So the idea is to have Bands at 20 m as dependent variables and band 8 A as the explanatory variable. I believe I should not use reducers as follow in the code because it is an image and not an image collection. Any tips on how to do that?

//Mascara do Cerrado
var polygon = ee.FeatureCollection('ft:1T3PyuGkCwptQjf5MZ5POd1iJJ330kUZU-avcjpT-');

var bands_MSI = ['B2', 'B3', 'B4', 'B8', 'B5', 'B6', 'B7', 'B8A', 'B11', 'B12'];

//Mascara de nuvens
var col_noclouds = function(image){
  var quality = image.select('QA60');
  var cloud01 = quality.eq(1);//Densas
  var cloud02 = quality.eq(2);// Cirrus
  var mask = cloud01.or(cloud02).not();
  return image.updateMask(mask);};

var base_collection = ee.ImageCollection('COPERNICUS/S2')
.filter(ee.Filter.lt('CLOUD_COVERAGE_ASSESSMENT', 5))
.filterBounds(polygon)
.filterDate('2017-01-01', '2017-12-31')
.map(col_noclouds)
.select(bands_MSI)
.median()
.select('B8','B12'); 

// Compute robust linear regression coefficients.
var robustLinearRegression = base_collection.reduce(
  ee.Reducer.robustLinearRegression({
    numX: 1,
    numY: 1
}));

// The results are array images that must be flattened for display.
// These lists label the information along each axis of the arrays.
var bandNames = [['B8'], // 0-axis variation.
                 ['B12']]; // 1-axis variation.

var rlrImage = robustLinearRegression.select(['coefficients']).arrayFlatten(bandNames);

// Display the OLS results.
Map.setCenter(-100.11, 40.38, 5);
Map.addLayer(rlrImage.select('B12'),
  {min: 0, max: 3000}, 'OLS');
  • A robust regression is not a spatial regression, which is something quite specific. Just because a statistic is applied to spatial data does not make it inherently "spatial". A robust regression is applied when one wants reduce the effect of outliers or high leverage data points that would invalidate an OLS. I like to use this statistic for downscaling climate data. However, I am scratching my head over applying this method to a timeseries. It is not indifferent to the iid assumption and time-series data is not independent. – Jeffrey Evans May 24 '18 at 14:49
  • The robust regression was just an example. I know it is supposed to be used to work with image cubes for temporal modelling. I just post this code to show the collections I want to regress and I was wondering if is there any option for spatial regression in GEE? There is a work I through I adapted from another code, but it is not quite what I want. Maybe it might help you: link – Osvaldo Pereira May 24 '18 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.