AI-generated Key Takeaways
- 
          
The
ee.data.computePixelsfunction computes a tile by performing an arbitrary computation on image data and returns the pixels as raw image data. - 
          
This function takes an object containing various parameters such as the expression to compute, file format, grid parameters, band IDs, visualization options, and a workload tag.
 - 
          
The resulting file format can be PNG by default, or other formats including
NUMPY_NDARRAYfor conversion to a structured NumPy array. - 
          
An example demonstrates how to use
ee.data.computePixelsin Python to retrieve pixel data for a Sentinel-2 image within a specified region and grid, with optional visualization options. 
Returns: The pixels as raw image data.
| Usage | Returns | 
|---|---|
ee.data.computePixels(params) | Object|Value | 
| Argument | Type | Details | 
|---|---|---|
params | Object | An object containing parameters with the following possible values:
    expression - The expression to compute.
    fileFormat - The resulting file format. Defaults to png. See
          ImageFileFormat
          for the available formats. There are additional formats that convert
          the downloaded object to a Python data object. These include:
          NUMPY_NDARRAY, which converts to a structured NumPy
          array.
    grid - Parameters describing the pixel grid in which to fetch data.
            Defaults to the native pixel grid of the data.
    bandIds - If present, specifies a specific set of bands from which to get
              pixels.
    visualizationOptions - If present, a set of visualization options to apply
                            to produce an 8-bit RGB visualization of the data,
                            rather than returning the raw data.
    workloadTag - User supplied tag to track this computation. | 
Examples
import ee import geemap.core as geemap
Colab (Python)
# Region of interest. coords = [ -121.58626826832939, 38.059141484827485, ] region = ee.Geometry.Point(coords) # Sentinel-2 median composite. image = (ee.ImageCollection('COPERNICUS/S2') .filterBounds(region) .filterDate('2020-04-01', '2020-09-01') .median()) # Make a projection to discover the scale in degrees. proj = ee.Projection('EPSG:4326').atScale(10).getInfo() # Get scales out of the transform. scale_x = proj['transform'][0] scale_y = -proj['transform'][4] # Make a request object. request = { 'expression': image, 'fileFormat': 'PNG', 'bandIds': ['B4', 'B3', 'B2'], 'grid': { 'dimensions': { 'width': 640, 'height': 640 }, 'affineTransform': { 'scaleX': scale_x, 'shearX': 0, 'translateX': coords[0], 'shearY': 0, 'scaleY': scale_y, 'translateY': coords[1] }, 'crsCode': proj['crs'], }, 'visualizationOptions': {'ranges': [{'min': 0, 'max': 3000}]}, } image_png = ee.data.computePixels(request) # Do something with the image...