1

I am trying to interpolate to increase the resolution of an image, but the results are not what I expected. I can't figure out what I am doing wrong.

var ols1 = ee.ImageCollection("NOAA/DMSP-OLS/CALIBRATED_LIGHTS_V4")
 .filterDate('2009-01-01', '2017-01-01');

var ols2 = ee.ImageCollection("NOAA/DMSP-OLS/CALIBRATED_LIGHTS_V4")
 .filterDate('1997-01-01', '2002-01-01');


var nl2012 = ols1;
var nl1997 = ols2;


var median1 = nl2012.reduce(ee.Reducer.mean());
var median2 = nl1997.reduce(ee.Reducer.mean());

var median = median1.subtract(median2);


var clipped = median;
var clipped1 = median1;

var zones = clipped.gt(1).add(clipped.gt(2)).add(clipped.gt(3)).add(clipped.gt(4)).add(clipped.gt(5)).add(clipped.gt(10));

// Define the visualization parameters.
var vizParams = {
  min: 1,
  max: 3};


var zonesMasked = zones.updateMask(zones.gte(4));

var image_10m = zones.resample('bilinear').reproject({
  crs: zones.projection().crs(),
  scale: 50
});

Map.addLayer(image_10m, vizParams, 'image_10m');


// Display the thresholds.
Map.setCenter(-74.6225, 4.712, 6);
Map.addLayer(zonesMasked);
Map.addLayer(zones);
2
  • what did you expect
    – nmtoken
    Commented Aug 16, 2018 at 8:32
  • I was hoping for an image with smaller size pixels Commented Aug 16, 2018 at 12:21

1 Answer 1

2

Please pay careful attention to the resample() docs, which state "This relies on the input image's default projection being meaningful, and so cannot be used on composites, for example. (Instead, you should resample the images that are used to create the composite.)" That explains why it isn't working in your example. It's also worth mentioning that it's weird to use bilinear resampling on categorical data. Here's using it on the input imagery:

var nl2012 = ee.ImageCollection("NOAA/DMSP-OLS/CALIBRATED_LIGHTS_V4")
 .filterDate('2009-01-01', '2017-01-01')
 .select('avg_vis')
 .map(function(i) { return i.resample() })

var nl1997 = ee.ImageCollection("NOAA/DMSP-OLS/CALIBRATED_LIGHTS_V4")
 .filterDate('1997-01-01', '2002-01-01')
 .select('avg_vis')
 .map(function(i) { return i.resample() })

var median1 = nl2012.reduce(ee.Reducer.mean());
var median2 = nl1997.reduce(ee.Reducer.mean());
var median = median1.subtract(median2);
Map.addLayer(median, {}, 'median')

var list = ee.List([1, 2, 3, 4, 5, 10]);
var thresholds = ee.Image.constant(list);
var zones1 = median.gt(thresholds).reduce('sum');
Map.addLayer(zones1, {min: 0, max: 6}, 'zones1');

Lastly, note that there is an implicit reproject (to maps mercator) when displaying in the Code Editor. Because scale is set from the zoom level, you may see different results upon zooming in and out.

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.