I am learning GIS using Google Earth Engine.
When learning "Changing detection" I have this code:
// Define the area of interest
var geometry = ee.Geometry.Polygon([[
[76.37639666685044, 11.766523239445169],
[76.37639666685044, 11.519036946599561],
[76.78426409849106, 11.519036946599561],
[76.78426409849106, 11.766523239445169]
]]);
var fireStart = ee.Date('2019-02-20');
var fireEnd = ee.Date('2019-02-25');
Map.centerObject(geometry, 10)
var s2 = ee.ImageCollection("COPERNICUS/S2")
// Write a function for Cloud masking
function maskS2clouds(image) {
var qa = image.select('QA60')
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
qa.bitwiseAnd(cirrusBitMask).eq(0))
return image.updateMask(mask)//.divide(10000)
.select("B.*")
.copyProperties(image, ["system:time_start"])
}
// Apply filters and cloud mask
var filtered = s2
.filter(ee.Filter.bounds(geometry))
.map(maskS2clouds)
.select('B.*')
// Create Before and After composites
var before = filtered
.filter(ee.Filter.date(
fireStart.advance(-2, 'month'), fireStart))
.median()
var after = filtered
.filter(ee.Filter.date(
fireEnd, fireEnd.advance(1, 'month')))
.median()
I don't understand what is the mean of "fireEnd.advance(1, 'month')" and "fireStart.advance(-2, 'month') "line.
What does it mean by "-2" or "1"?
GIS
question. Rather it is a programming question and post it to Stackoverflow.-2
you're advancing backwards :-). You get a new date two months before the one you're callingadvance()
on. With1
you get next month.