[GIS] Earth engine error: Layer 1: Layer error: Image.visualize: Parameter ‘image’ is required

classificationgoogle-earth-engine

For land use classification of my shapefile, When I use Landsat 4 collection, got an error:

Layer 1: Layer error: Image.visualize: Parameter 'image' is required.

but in the case of Landsat 8, there is no such problem.

Codes here:

var image = ee.Image(ee.ImageCollection('LANDSAT/LT04/C01/T1_TOA')  
    .filterBounds(table)  
    .filterDate('1984-04-01', '1984-12-31')    
    .sort('CLOUD_COVER')  
    .first());  

var visParams = {   
      bands: ['B3', 'B2', 'B1'],  
      min: 0,  
      max: 3000,  
      gamma: 1.4,
};  
Map.addLayer(image, visParams);  

How do I solve this?

Best Answer

There is no image in this time interval. You can test this by simply add a print image line.

var image = ee.ImageCollection('LANDSAT/LT04/C01/T1_TOA')
.filterDate('1984-04-01', '1990-12-31')
.sort('CLOUD_COVER')
.first();

print(image)

var visParams = {
bands: ['B3', 'B2', 'B1'],
min: 0,
max: 3000,
gamma: 1.4, };
Map.addLayer(image, visParams); 

If you change the dates to e.g. 1990 than you can see a image inside the collection.