Google Earth Engine – How to Get the Geometry of an Image

geometrygoogle-earth-engineimage

I have an image which is from type 'ee.Image' and I want to extract its geometry so that:

im_geo = im.geometry();

but the geometry function of 'ee.Image' is DEPRECATED!

Is there another way for it?

Best Answer

That function still works. As far as I can tell, it's deprecated from the ee.Image docs because it extends beyond just images at this point.

var im = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR").first();
print("im", im);

var im_geo = im.geometry();
print("im_geo", im_geo);

For example, you can use Element.geometry() to find the geometry of a FeatureCollection as well:

var LSIB = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017")
  .filter(ee.Filter.eq('country_co','GL'));
print("LSIB",LSIB);
var LSIB_geo = LSIB.geometry();
print("LSIB_geo",LSIB_geo);