2

How can I get the 'id' field shown when I print a FeatureCollection in Google Earth Engine? I tried get('id') or get('system:index') but it didn't work (returns null).

3

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

0

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 .set() method.

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'))
  • Thanks for reply Kel, but I mean the 'id' field that is shown under collection name after type, not its properties. How can I get this id? ImageCollection LANDSAT/LE07/C01/T1_SR (7 elements) type: ImageCollection id: LANDSAT/LE07/C01/T1_SR version: 1544793856359967 bands: [] features: List (7 elements) properties: Object (20 properties) – Shahriar49 Dec 14 '18 at 21:44
  • Oh, sorry. For whatever reason I thought you meant from a FeatureCollection. I don't think you can get the ID of the ImageCollection from the variable. You can look up the collection IDs using the Earth Engine Data Catalog though. – Kel Markert Dec 19 '18 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.