0% found this document useful (0 votes)
178 views2 pages

NDBI Calculation Using Landsat 8 Data

The document describes functions to perform cloud masking on Landsat 8 SR data and calculate the Normalized Difference Built-up Index (NDBI) for a Landsat image collection for Indonesia from 2014. Specifically, it defines a function to mask cloudy pixels using the pixel QA band, filters and maps the function over an image collection for 2014, calculates the NDBI, thresholds the NDBI, calculates pixel areas, reduces pixel counts by geometry, and exports the results.

Uploaded by

gilang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views2 pages

NDBI Calculation Using Landsat 8 Data

The document describes functions to perform cloud masking on Landsat 8 SR data and calculate the Normalized Difference Built-up Index (NDBI) for a Landsat image collection for Indonesia from 2014. Specifically, it defines a function to mask cloudy pixels using the pixel QA band, filters and maps the function over an image collection for 2014, calculates the NDBI, thresholds the NDBI, calculates pixel areas, reduces pixel counts by geometry, and exports the results.

Uploaded by

gilang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//Membuat cloud masking

// Function to cloud mask from the pixel_qa band of Landsat 8 SR data.


function maskL8sr(image) {
// Bits 3 and 5 are cloud shadow and cloud, respectively.
var cloudShadowBitMask = 1 << 3;
var cloudsBitMask = 1 << 5;

// Get the pixel QA band.


var qa = [Link]('pixel_qa');

// Both flags should be set to zero, indicating clear conditions.


var mask = [Link](cloudShadowBitMask).eq(0)
.and([Link](cloudsBitMask).eq(0));

// Return the masked image, scaled to reflectance, without the QA bands.


return [Link](mask).divide(10000)
.select("B[0-9]*")
.copyProperties(image, ["system:time_start"]);
}

// Map
var image = [Link]('LANDSAT/LC08/C01/T1_SR')//Citra landsat 7
.filterDate('2014-01-01', '2014-12-31')//Rentangan waktu
.map(maskL8sr)//Memfungsikan cloud masking
.mean()//Rata-rata
.clip(table);//Clip dengan shp

//Calculate NDBI
var ndbi = [Link](['B6', 'B5'])
.rename('NDBI')
//Calculate NDBI diatas nilai 0 menjadi 1 dan dibawah 0 dihapus
var ndbi1 = [Link](0)//Diatas nilai 0 dijadikan 1
.selfMask()//Selain 1 dihilangkan

//Membuat Display warna pada layer


var ndbiVis = {
bands: ['NDBI'],
min: -1.0,
max: 1.0,
palette: ['Green','Yellow','Red']
};

// Calculate pixel area km2


var area = [Link]([Link]()).divide(1000000)

//Pixel di reduce (jumlah)


var reducers = [Link]()
//Untuk mendapatkan koordinat area di pixel
var geom = [Link](table)
//Menghitung pixel area dan menampilkannya
var stats = [Link]({
reducer: reducers,
geometry: [Link](),
scale: 20,
bestEffort: true,
});
// Display the dictionary in console
print(stats);
// Display the results
[Link](112.43, -7.73, 9);
[Link](ndbi1, ndbiVis, 'NDBI');

//Export map
[Link]({
image:ndbi,
description:'AVG_LAO_NDBI_2014',//Nama file yang akan disimpan
folder : 'LANDSAT NDBI SUBDAS',//Nama folder yang akan disimpan
scale: 20,//Skala
region: table});//Geometry

You might also like