Annuncio: tutti i progetti non commerciali registrati per l'utilizzo di Earth Engine prima del
15 aprile 2025 devono
verificare l'idoneità non commerciale per mantenere l'accesso a Earth Engine.
ee.data.getPixels (Python only)
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Recupera i pixel da un asset immagine.
Restituisce:
I pixel come dati immagine non elaborati.
Utilizzo | Resi |
ee.data.getPixels(params) | Oggetto|Valore |
Argomento | Tipo | Dettagli |
params | Oggetto | Un oggetto contenente parametri con i seguenti valori possibili:
assetId : l'ID asset per cui ottenere i pixel. Deve essere un asset immagine.
fileFormat : il formato file risultante. Il valore predefinito è png. Consulta
ImageFileFormat
per i formati disponibili. Esistono altri formati che convertono
l'oggetto scaricato in un oggetto dati Python. Questi includono:
NUMPY_NDARRAY , che viene convertito in un array NumPy
strutturato.
grid - Parametri che descrivono la griglia di pixel in cui recuperare i dati.
Il valore predefinito è la griglia di pixel nativa dei dati.
region - If present, the region of data to return, specified as a GeoJSON
geometry object (see RFC 7946).
bandIds - Se presente, specifica un insieme specifico di bande da cui ottenere
i pixel.
visualizationOptions - Se presente, un insieme di opzioni di visualizzazione da applicare
per produrre una visualizzazione RGB a 8 bit dei dati,
anziché restituire i dati non elaborati. |
Esempi
Configurazione di Python
Consulta la pagina
Ambiente Python per informazioni sull'API Python e sull'utilizzo di
geemap
per lo sviluppo interattivo.
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 quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 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```"]]