For debugging it would be great to figure out which EE object type an object is.
Example code which adds a buffer to a point in a random area:
var polygon = ee.Geometry.Point([0,51.477]).buffer(10000); // a circle in London
var random_points = ee.FeatureCollection.randomPoints(polygon.bounds(), 100); // 100 random points in London
var point_list = random_points.geometry().geometries();
print(point_list); // prints -- List (100 elements)
var one_point = point_list.get(10); // The 11th point.
print(one_point); // prints -- Point (-0.03, 51,52)
var small_circle = one_point.buffer(100);
print(small_circle); // Error -- one_point.buffer is not a function...
Since the console prints Point..., I would think that one_point is of type ee.Geometry.Point. However, according to the docs ee.Geometry objects are supposed to support the .buffer() function, which this one does not support. Hence I assume it's a different kind of object but I have no clue which. When I code in Earth Engine, I run into these kind of problems very frequently.
Is there a way to figure out which type of EE object an object is? Something like the fantasy .EE_OBJECT_TYPE() function here:
print(polygon.EE_OBJECT_TYPE()); // should print -- ee.Geometry.Polygon
print(one_point.EE_OBJECT_TYPE()); // should print -- ee.WhateverObjectThisIs
Non-solutions:
print(my_object)often indicates the type of object but, as the example above demonstrates, this is not always the case (or correct).my_object.type()only specifies the kind ofee.Geometryand doesn't work on any other EE objects according to the docs.my_object.typeOf()always returnsobjectfor EE objects.
instanceofand it's pretty helpful. Thanks! However, I'm looking for a function that returns the prototype hierarchy of an object -- i. e. all the objects (or just EE objects) for whichinstanceofwould returntrue. – Joooeey Sep 25 '17 at 19:37ee.Geometry(ee.Feature(ee.Geometry.Point([0,51.477])))returns an ambiguous object. It's mostly a feature because it's printed as a feature and only supports the functions of anee.Feature object. However it's an instance ofee.Geometryand not ofee.Feature. – Joooeey Sep 25 '17 at 22:33