TransWikia.com

Building model for extraction of urban features on Google Earth Engine

Geographic Information Systems Asked by Akshinde on February 13, 2021

I’m trying to build a model for extraction of urban features on Google Earth Engine, I’ve calculated NDVI & NDBI and subtracted them to get the built-up area but I’m unable to display it on the map. It is showing the error:- Layer 3: Layer error: Parameter ‘expression’ is required.

var landsat = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
                .filterBounds(varanasi);
Map.centerObject(varanasi,9);
// Printing an image collection

var imgfunc = function(image){
  var result = image.normalizedDifference(['B5','B4'])
                    .rename('ndvi')
                    return image.addBands(result);
};
var ndviimage = landsat.map(imgfunc);
var ndviband = ndviimage.select('ndvi');
Map.addLayer(ndviband.mean().clip(varanasi), { min: -1, max: 1,palette: ['blue', 'white', 'green']},'NDVI');
//NDBI
var ndbifunc = function(ndbiimage){
  var ndbiresult = ndbiimage.normalizedDifference(['B6','B5'])
                    .rename('ndbi')
                    return ndbiimage.addBands(ndbiresult);
  
};
var ndbiimage = landsat.map(ndbifunc);
var ndbiband = ndbiimage.select('ndbi');
Map.addLayer (ndbiband.mean().clip(varanasi), { min: -1, max: 1,palette: [ 'yellow', 'blue']},'NDBI');
//var diff = ndviband.mean().subtract(ndviband);
//Map.addLayer(diff,'Built up Area');
var diff = landsat.mean().expression(ndbiband-ndviband);
Map.addLayer(diff, {min: -10, max: 10, palette: ['FF0000', '00FF00']});

Link to my GEE Code

One Answer

I found a couple of mistakes in your code. But first, you have misunderstood the expression function usage.

It only excepts expression in string format. So, you cant use variables directly. If you want to use variables use a dictionary to map them in the string.

primary_image.expression("x-y",{"x":image_1,"y":image_2})

// If you want to access primary Image use b(band_no) in string
expression("x-y+b(0)",{"x":image_1,"y":image_2})

In your code first, you have used variables in the expression directly, and second, you are passing image collection to expression take mean of your image collection and then subtract images. So your code will be

var ndbiband_image = ndbiband.mean().clip(varanasi);
var ndviband_image = ndviband.mean().clip(varanasi);
var diff = landsat.mean().expression("ndbiband-ndviband",{"ndbiband":ndbiband_image,"ndviband":ndviband_image});

Answered by mohit kaushik on February 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP