Monday, 6 November 2017

google earth engine: access ImageCollection features list?


the console gives me a view into the 'properties' of the ImageCollection object:



ImageCollection LANDSAT/LC08/C01/T1_SR (107 elements)
type: ImageCollection
id: LANDSAT/LC08/C01/T1_SR
version: 1524816484446982
bands: []
features: List (107 elements)
properties: Object (23 properties)

and the docs describe methods to access the properties of the properties object.


problem: how do I read the features list? I want the 'id' property of each of the images (which the console can show me). I have tried:



var imageList = myImageCollection.toList(100).features;

and the error is: Cannot read property '0' of undefined


hoping for an undocumented method, I tried:


var imageList = myImageCollection.features();

and the error is: myImageCollection.features is not a function



Answer



You can access the ID of an image using ee.Image.id(). For example:


var geometry = ee.Geometry.Point([-112.62, 40.98]);


var myImageCollection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(geometry);

// Create a list of image objects.
var imageList = myImageCollection.toList(100);
print('imageList', imageList);

// Extract the ID of each image object.
var id_list = imageList.map(function(item) {

return ee.Image(item).id();
});
print('id_list', id_list);

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...