I am new to coding and have just started using the Google Earth Engine code editor. I am on Lab 2 provided by Google Earth Engine: https://docs.google.com/document/d/1NojoqhGbsBnIWE2OSwYCgMmRxeZDn7F1g3kkNuMGJ1E/edit
When in complete the practical to number 1.a.v. I get two errors.
See the complete code below:
var myd09 = ee.ImageCollection('MODIS/006/MYD09GA');
// Define a region of interest as a point at SFO airport.
var sfoPoint = ee.Geometry.Point(-122.3774, 37.6194);
// Center the map at that point.
Map.centerObject(sfoPoint, 16);
// Get a surface reflectance image from the MODIS MYD09GA collection.
var modisImage = ee.Image(myd09.filterDate('2011-08-28').first());
// Use these MODIS bands for red, green, blue, respectively.
var modisBands = ['sur_refl_b01', 'sur_refl_b04', 'sur_refl_b03'];
// Define visualization parameters for MODIS.
var modisVis = {bands: modisBands, min: 0, max: 3000};
// Add the MODIS image to the map.
Map.addLayer(modisImage, modisVis, 'MODIS');
// Get the scale of the data from the first band's projection:
var modisScale =
modisImage.select('sur_refl_b01').projection().nominalScale();
print('MODIS scale:', modisScale);
The errors i receive are:
1) Number (Error) Image.select: Parameter 'input' is required. 2) MODIS: Layer error: Asset is not an Image or ImageCollection.
Is anyone able to help me with the solution or point me in the right direction!
Thank you, Harriet Wilson
Yes, if you print the image (to see its information), like:
print(modisImage)
you'll see that it is null, so I printed out the collection:
print(myd09)
and found that the collection starts on 2016, so just change the filter Date:
var modisImage = ee.Image(myd09.filterDate('2016-08-11').first());