I am new to Google Earth Engine and often faced the problem that I have the mistake of Syntax Errors where the line and the sign number is shown (for example 29:1). However, there is a mistake within my script with filterBounds. I've checked the variable, the spelling and the correct coding with ChatGPT, google developers, mozilla developers ( I guess because it's JAVA script) and stackoverflow. The way I wrote filterBounds and the connection to the variable in () should be correct. Still the script doesn't work.... I think I should post the whole script: I am calculating the NDVI for three (for the first trial) geometry points with Landsat images. They are summarized with roi_list and then roi. Within the script filterBounds is defined with filterBounds(roi) - And there GEE shows Syntax Error Unexpected Token (29:1)
`
var l8sr = ee.Image('LANDSAT/LC08/C01/T1_SR');
var roi_list = [ee.Feature(ee.Geometry.Point(26.1193686,57.6993804), {name: 'Vegplot2'}),
ee.Feature(ee.Geometry.Point(26.1199795,57.6994959), {name: 'Vegplot2a'}),
ee.Feature(ee.Geometry.Point(26.1204113, 57.6995053), {name: 'Vegplot3'})];
var roi = ee.FeatureCollection(roi_list);
var timeField = 'system:time_start';
function maskL8sr(image) {
var cloudShadowBitMask = 1 << 3;
var cloudsBitMask = 1 << 5;
var qa = image.select('pixel_qa');
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0));
return image.updateMask(mask).divide(10000)
.select('B[0-9]*')
.copyProperties(image,['system:time_start']);
}
var addVariables = function(image) {
var date = ee.Date(image.get(timeField));
var years = date.difference(ee.Date('2017-01-01'),'year');
return image
.addBands(image.normalizedDifference(['B5','B4']).rename('NDVI'))
.addBands(ee.Image(years).rename('t'))
.float()
.addBands(ee.Image.constant(1));
};
function name(vegplot2, vegplot2a, vegplot3)
// Code hier
filterBounds(roi)
.map(maskL8sr)
.map(addVariables)
//Plot a time series of NDVI at a single location
var l8Chart = ui.Chart.image.seriesByRegion(filteredLandsat,
roi,
ee.Reducer.mean(),
'NDVI')
.setChartType('ScatterChart')
.setOptions({
title: 'Landsat 8 NDVI time series at ROI',
vAxis: {title: 'NDVI'},
lineWidth: 1,
pointSize: 4,
series: {
0: {color: '#FF0000'}, // Vegplot2
1: {color: '#FFFF00'}, // Vegplot2a
2: {color: '#00FF00'}, // Vegplot3
}
});
print(l8Chart);
return wert;
Like I said in the beginning, I am new to Google Earth Engine. I also don't have many experience with coding, maybe a little bit HTML, but this only helps for recognizing colors. Therefore, it would be great if you show patience if I don't get your advice immediately. Thanks ahead and have a nice day.
ask Chatgpt, google and mozilla developers and oder stackflow discussion, check spelling, comparing other scripts, realizing they are way to different from mine and trying to understand the connection within the script.