I am trying to use in Google Earth Engine the function area()
or centroid()
on a simple polygon. According to the documentation, there seems to exist a method area()
for objects ee.Geometry.Polygon. However, I get an error message with this simple code:
var polygon = ee.Geometry.Polygon([
[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]
]);
var a = area(polygon);
var aa = polygon.area();
Gives message:
"area" is not defined in this scope.
What am I doing wrong?
var a = area(polygon);
is probably what is giving the error. Remove it. The remainder of the code looks valid according to developers.google.com/earth-engine/geometry_visualization_info