ee.data.getPixels (Python only)
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Pobiera piksele z komponentu z obrazem.
Zwraca: piksele w postaci surowych danych obrazu.
Wykorzystanie | Zwroty |
ee.data.getPixels(params) | Obiekt|Wartość |
Argument | Typ | Szczegóły |
params | Obiekt | Obiekt zawierający parametry o tych możliwych wartościach:
assetId – identyfikator komponentu, dla którego chcesz pobrać piksele. Musi to być komponent z obrazem.
fileFormat – wynikowy format pliku. Domyślna wartość to png. Dostępne formaty znajdziesz w sekcji ImageFileFormat. Istnieją dodatkowe formaty, które przekształcają pobrany obiekt w obiekt danych Pythona. Obejmują one:
NUMPY_NDARRAY , która jest konwertowana na uporządkowaną tablicę NumPy.
grid – parametry opisujące siatkę pikseli, z której mają być pobierane dane.
Domyślnie jest to natywna siatka pikseli danych.
region – jeśli występuje, region danych do zwrócenia, określony jako obiekt geometryczny GeoJSON (patrz RFC 7946).
bandIds – jeśli występuje, określa konkretny zestaw pasm, z których mają być pobierane piksele.
visualizationOptions – jeśli występuje, zestaw opcji wizualizacji do zastosowania w celu utworzenia 8-bitowej wizualizacji RGB danych zamiast zwracania surowych danych. |
Przykłady
Konfiguracja Pythona
Informacje o interfejsie Python API i używaniu geemap
do interaktywnego programowania znajdziesz na stronie
Środowisko Python.
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...
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 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```"]]