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
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 of
ee.Geometryand doesn't work on any other EE objects according to the docs.
objectfor EE objects.