I modified your code to print the dimensions of a specified region (ROI).
var ROI = ee.Geometry.Rectangle(-82.5574, 35.5958, -82.5563, 35.59515); // define area
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
.filterDate('2014-05-01', '2015-10-01')
.filterBounds(ROI)
.limit(1);
var composite = ee.Algorithms.Landsat.simpleComposite(collection);
var image = composite.clip(ROI);
Map.centerObject(ROI);
Map.addLayer(composite, {bands: 'B4,B3,B2', min:0, max:100}, "composite", false);
Map.addLayer(image, {bands: 'B4,B3,B2', min:0, max:100},"image");
// Extract projection information from the first band of a sample image in the collection.
var sample = ee.Image(collection.first());
var projection = sample.select('B1').projection();
// Reproject the composite image to the selected projection.
image = composite.reproject(projection).clip(ROI);
print('image information', image);
Note that:
- Because image collections may contain images with many different projections, you need to specify the projection of your desired output in order to get back meaningful dimensions. In the example above I used the projection information from the first band of a sample image.
- Bands within an image may have different projections. (This is the case for Landsat 8 images.)
- I made the ROI smaller, so you can see the individual pixels when added to the map.
- I limited the collection to a single image that intersects the ROI, so it is easier to interpret the results.
If you want to access the information on the client side, you can do the following:
// Return the image metadata to the client.
var image_info = image.getInfo();
// On the clientside, using Javascript, print out the dimensions.
print('band B1 dimensions: ' + image_info.bands[0].dimensions);
While it is possible to construct images in Earth Engine that store pixel information as multi-dimensional arrays, most images (including the Landsat collection shown in your example) have scalar values (i.e. 0-dimensional arrays) so it is not necessary to use ee.Array object methods to extract information.
For the record, here is a good way to do this:
var imageCollection = ee.ImageCollection("LANDSAT/LT05/C01/T1");
var months = ee.List.sequence(1, 12);
var composites = ee.ImageCollection.fromImages(months.map(function(m) {
var filtered = imageCollection.filter(ee.Filter.calendarRange({
start: m,
field: 'month'
}));
var composite = ee.Algorithms.Landsat.simpleComposite(filtered);
return composite.normalizedDifference(['B4', 'B3']).rename('NDVI')
.set('month', m);
}));
print(composites);
var check = ee.Image(composites.first());
Map.addLayer(check, {min: 0, max: 1}, 'check');
For the search robots, this is a "temporally grouped reduction."
Best Answer
You can use ee.Algorithms.Describe() (bit hidden in the documentation)
this should work :