ee.data.getPixels (Python only)
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Récupère les pixels d'un composant Image.
Renvoie les pixels sous forme de données d'image brutes.
Utilisation | Renvoie |
ee.data.getPixels(params) | Objet|Valeur |
Argument | Type | Détails |
params | Objet | Objet contenant des paramètres avec les valeurs possibles suivantes :
assetId : ID de l'asset pour lequel obtenir les pixels. Doit être un composant Image.
fileFormat : format du fichier obtenu. La valeur par défaut est "png". Consultez ImageFileFormat pour connaître les formats disponibles. Il existe d'autres formats qui convertissent l'objet téléchargé en objet de données Python. Par exemple, NUMPY_NDARRAY est converti en tableau NumPy structuré.
grid : paramètres décrivant la grille de pixels dans laquelle récupérer les données.
La valeur par défaut est la grille de pixels native des données.
region : si elle est présente, la région de données à renvoyer, spécifiée sous la forme d'un objet de géométrie GeoJSON (voir RFC 7946).
bandIds : si cet élément est présent, il spécifie un ensemble de bandes à partir desquelles obtenir des pixels.
visualizationOptions : ensemble d'options de visualisation à appliquer, le cas échéant, pour produire une visualisation RVB 8 bits des données, plutôt que de renvoyer les données brutes. |
Exemples
Configuration de Python
Consultez la page
Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap
pour le développement interactif.
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...
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[null,null,["Dernière mise à jour le 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```"]]