Anuncio: Todos los proyectos no comerciales registrados para usar Earth Engine antes del
15 de abril de 2025 deben
verificar su elegibilidad no comercial para mantener el acceso a Earth Engine.
ee.data.getPixels (Python only)
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Recupera píxeles de un recurso de imagen.
Devuelve los píxeles como datos de imagen sin procesar.
Uso | Muestra |
ee.data.getPixels(params) | Objeto|Valor |
Argumento | Tipo | Detalles |
params | Objeto | Objeto que contiene parámetros con los siguientes valores posibles:
assetId : Es el ID del recurso para el que se obtendrán píxeles. Debe ser un recurso de imagen.
fileFormat : Es el formato de archivo resultante. El valor predeterminado es png. Consulta ImageFileFormat para ver los formatos disponibles. Existen formatos adicionales que convierten el objeto descargado en un objeto de datos de Python. Incluyen los siguientes:
NUMPY_NDARRAY , que se convierte en un array NumPy
estructurado.
grid : Son los parámetros que describen la cuadrícula de píxeles en la que se recuperarán los datos.
El valor predeterminado es la cuadrícula de píxeles nativa de los datos.
region : Si está presente, es la región de datos que se devolverá, especificada como un objeto de geometría GeoJSON (consulta RFC 7946).
bandIds : Si está presente, especifica un conjunto específico de bandas de las que se obtendrán los píxeles.
visualizationOptions : Si está presente, es un conjunto de opciones de visualización para aplicar
y producir una visualización RGB de 8 bits de los datos,
en lugar de devolver los datos sin procesar. |
Ejemplos
Configuración de Python
Consulta la página
Entorno de Python para obtener información sobre la API de Python y el uso de geemap
para el desarrollo interactivo.
import ee
import geemap.core as geemap
Colab (Python)
# Region of interest.
coords = [
-121.58626826832939,
38.059141484827485,
]
region = ee.Geometry.Point(coords)
# Get a Sentinel-2 image.
image = (ee.ImageCollection('COPERNICUS/S2')
.filterBounds(region)
.filterDate('2020-04-01', '2020-09-01')
.sort('CLOUD_COVERAGE_ASSESSMENT')
.first())
image_id = image.getInfo()['id']
# 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 = {
'assetId': image_id,
'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.getPixels(request)
# Do something with the image...
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-26 (UTC)
[null,null,["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003e\u003ccode\u003eee.data.getPixels\u003c/code\u003e fetches raw image data or visualized 8-bit RGB data from an Earth Engine image asset.\u003c/p\u003e\n"],["\u003cp\u003eThe function requires specifying the asset ID and allows customization of file format, pixel grid, region, bands, and visualization options.\u003c/p\u003e\n"],["\u003cp\u003eUsers can define the output region, select specific bands for extraction, and apply visualization parameters for an RGB representation.\u003c/p\u003e\n"],["\u003cp\u003ePython examples demonstrate the usage of \u003ccode\u003eee.data.getPixels\u003c/code\u003e with the necessary parameters and retrieving image data.\u003c/p\u003e\n"]]],[],null,["# ee.data.getPixels (Python only)\n\n\u003cbr /\u003e\n\nFetches pixels from an image asset.\n\n\u003cbr /\u003e\n\nReturns:\nThe pixels as raw image data.\n\n| Usage | Returns |\n|-----------------------------|---------------|\n| `ee.data.getPixels(params)` | Object\\|Value |\n\n| Argument | Type | Details |\n|----------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `params` | Object | An object containing parameters with the following possible values: `assetId` - The asset ID for which to get pixels. Must be an image asset. `fileFormat` - The resulting file format. Defaults to png. See [ImageFileFormat](https://developers.google.com/earth-engine/reference/rest/v1/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. `region` - If present, the region of data to return, specified as a GeoJSON geometry object (see RFC 7946). `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. |\n\nExamples\n--------\n\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Region of interest.\ncoords = [\n -121.58626826832939,\n 38.059141484827485,\n]\nregion = ee.Geometry.Point(coords)\n\n# Get a Sentinel-2 image.\nimage = (ee.ImageCollection('COPERNICUS/S2')\n .filterBounds(region)\n .filterDate('2020-04-01', '2020-09-01')\n .sort('CLOUD_COVERAGE_ASSESSMENT')\n .first())\nimage_id = image.getInfo()['id']\n\n# Make a projection to discover the scale in degrees.\nproj = ee.Projection('EPSG:4326').atScale(10).getInfo()\n\n# Get scales out of the transform.\nscale_x = proj['transform'][0]\nscale_y = -proj['transform'][4]\n\n# Make a request object.\nrequest = {\n 'assetId': image_id,\n 'fileFormat': 'PNG',\n 'bandIds': ['B4', 'B3', 'B2'],\n 'grid': {\n 'dimensions': {\n 'width': 640,\n 'height': 640\n },\n 'affineTransform': {\n 'scaleX': scale_x,\n 'shearX': 0,\n 'translateX': coords[0],\n 'shearY': 0,\n 'scaleY': scale_y,\n 'translateY': coords[1]\n },\n 'crsCode': proj['crs'],\n },\n 'visualizationOptions': {'ranges': [{'min': 0, 'max': 3000}]},\n}\n\nimage_png = ee.data.getPixels(request)\n# Do something with the image...\n```"]]