I am trying to extract column and row information from a raster in Google Earth Engine, but am having some trouble doing so. Here is sample code.
var ROI = ee.Geometry.Rectangle(-82.56277, 35.58935,-82.53436, 35.59996); // define area
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
.filterDate('2014-05-01', '2015-10-01');
var composite = ee.Algorithms.Landsat.simpleComposite(collection);
var image = composite.clip(ROI);
Map.centerObject(ROI);
Map.addLayer(image,{},"image");
print(image.arrayLength(image,0));
However, image.arrayLength(image,0) returns the error message
Too many (3) arguments to function: Image.arrayLength(input, axis)
Returns the length of each pixel's array along the given axis.
Args:
input (Image): Input image.
axis (Integer): The axis along which to take the length.
I have tried to enter image.arrayLength(0) as well, but that returns the whole image. According to the arrayLength help page, it seems like it should return an integer with the number of pixels in the specified axis.
The information is contained if you drill down into the image object (Image->bands->0->dimensions->0 or Image->bands->0->dimensions->1), and the object appears to be a json object, but I can't figure out how to access this information.
Best Answer
I modified your code to print the dimensions of a specified region (ROI).
Note that:
If you want to access the information on the client side, you can do the following:
While it is possible to construct images in Earth Engine that store pixel information as multi-dimensional arrays, most images (including the Landsat collection shown in your example) have scalar values (i.e. 0-dimensional arrays) so it is not necessary to use ee.Array object methods to extract information.