How can I get the 'id' field shown when I print a FeatureCollection in Google Earth Engine? I tried
get('system:index') but it didn't work (returns null).
Even though "id" is listed, it's actually "system:id" internally
// import points as FC var myPoints = ee.FeatureCollection("users/me/important/myFC"); // get the system:id and convert to string // note this is actually an object on the server var sysID_serverObj = ee.String(myPoints.get("system:id")); // getInfo() converts to string on the server var sysID_serverStr = sysID_serverObj.getInfo() // cut the string down for the fileName needed var fileName = sysID_serverStr.slice(7,100); print(fileName)
More info on client vs server handling of objects here: https://developers.google.com/earth-engine/client_server
Properties that are associate with FeatureCollections and Features within that collection should not be confused, they can have two seperate sets of properties. Earth Engine is returning null when you try to get that property from the FC because it does not exist (even though individual features may have it). You can try explicitly setting the property on the FeatureCollection that you want using the
var len = table.toList(10000).length().subtract(1) var idList = ee.List.sequence(0,len) var tableWithId = table.set('id',idList) print(tableWithId.get('id'))