2

I want to know the shape, that is the height and width of an ee.Image, how can i get that?

I have been looking through the documentation to see if there is a function for that, but I could not find, I have tried to get the value of the edges of my geometry, which is a rectangle, and then calculate it's amplitude in x and y, but I get a very small result, which does not make sense.

3

An ee.Image does not necessarily have a height or width if it has been computed from multiple sources. However, if it is an image that has been persisted to an asset you can get that information from the band metadata. Bands within an image can different sizes and coordinate reference systems, so there is not necessarily one answer to what you are asking. To see the crs, resolution, and image sizes - print out the metadata of the image.

ee.ImageCollection("COPERNICUS/S2_SR")
  .first()
  .evaluate(
    function(img) {
      print(img.bands);
    }   
  );

Which yields an array of objects like this:

{
   "id":"B1",
   "data_type":{
      "type":"PixelType",
      "precision":"int",
      "min":0,
      "max":65535
   },
   "dimensions":[
      1830,
      1830
   ],
   "crs":"EPSG:32635",
   "crs_transform":[
      60,
      0,
      499980,
      0,
      -60,
      3000000
   ]
}

The dimensions are the x and y size in pixels, and the 0 and 4 index of the crs_transform are the x and y pixel resolutions, respectively.

| improve this answer | |

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.