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.ImageCollection.getRegion
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Genera un array de valores para cada tupla [píxel, banda, imagen] en una ImageCollection. El resultado contiene filas de id, longitud, latitud, hora y todas las bandas de cada imagen que se cruza con cada píxel de la región determinada. Si intentas extraer más de 1,048,576 valores, se producirá un error.
Uso | Muestra |
---|
ImageCollection.getRegion(geometry, scale, crs, crsTransform) | Lista |
Argumento | Tipo | Detalles |
---|
esta: collection | ImageCollection | Es la colección de imágenes de la que se extraerán los datos. |
geometry | Geometría | Es la región para la que se extraerán los datos. |
scale | Número de punto flotante, valor predeterminado: nulo | Es una escala nominal en metros de la proyección en la que se trabajará. |
crs | Proyección (opcional) | Proyección en la que se trabajará. Si no se especifica, el valor predeterminado es EPSG:4326. Si se especifica además de la escala, la proyección se vuelve a ajustar a la escala especificada. |
crsTransform | Lista, valor predeterminado: null | Es el array de valores de transformación del CRS. Es un ordenamiento de fila principal de una transformación afín de 3 x 2. Esta opción es mutuamente excluyente con la opción de escala y reemplazará cualquier transformación ya establecida en la proyección determinada. |
Ejemplos
Editor de código (JavaScript)
// A Landsat 8 TOA image collection (3 months at a specific point, RGB bands).
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.Point(-90.70, 34.71))
.filterDate('2020-07-01', '2020-10-01')
.select('B[2-4]');
print('Collection', col);
// Define a region to get pixel values for. This is a small rectangle region
// that intersects 2 image pixels at 30-meter scale.
var roi = ee.Geometry.BBox(-90.496353, 34.851971, -90.495749, 34.852197);
// Display the region of interest overlaid on an image representative. Note
// the ROI intersection with 2 pixels.
var visParams = {
bands: ['B4', 'B3', 'B2'],
min: 0.128,
max: 0.163
};
Map.setCenter(-90.49605, 34.85211, 19);
Map.addLayer(col.first(), visParams, 'Image representative');
Map.addLayer(roi, {color: 'white'}, 'ROI');
// Fetch pixel-level information from all images in the collection for the
// pixels intersecting the ROI.
var pixelInfoBbox = col.getRegion({
geometry: roi,
scale: 30
});
// The result is a table (a list of lists) where the first row is column
// labels and subsequent rows are image pixels. Columns contain values for
// the image ID ('system:index'), pixel longitude and latitude, image
// observation time ('system:time_start'), and bands. In this example, note
// that there are 5 images and the region intersects 2 pixels, so n rows
// equals 11 (5 * 2 + 1). All collection images must have the same number of
// bands with the same names.
print('Extracted pixel info', pixelInfoBbox);
// The function accepts all geometry types (e.g., points, lines, polygons).
// Here, a multi-point geometry with two points is used.
var points = ee.Geometry.MultiPoint([[-90.49, 34.85], [-90.48, 34.84]]);
var pixelInfoPoints = col.getRegion({
geometry: points,
scale: 30
});
print('Point geometry example', pixelInfoPoints);
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)
# A Landsat 8 TOA image collection (3 months at a specific point, RGB bands).
col = (
ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.Point(-90.70, 34.71))
.filterDate('2020-07-01', '2020-10-01')
.select('B[2-4]')
)
display('Collection', col)
# Define a region to get pixel values for. This is a small rectangle region
# that intersects 2 image pixels at 30-meter scale.
roi = ee.Geometry.BBox(-90.496353, 34.851971, -90.495749, 34.852197)
# Display the region of interest overlaid on an image representative. Note
# the ROI intersection with 2 pixels.
vis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.128, 'max': 0.163}
m = geemap.Map()
m.set_center(-90.49605, 34.85211, 19)
m.add_layer(col.first(), vis_params, 'Image representative')
m.add_layer(roi, {'color': 'white'}, 'ROI')
display(m)
# Fetch pixel-level information from all images in the collection for the
# pixels intersecting the ROI.
pixel_info_bbox = col.getRegion(geometry=roi, scale=30)
# The result is a table (a list of lists) where the first row is column
# labels and subsequent rows are image pixels. Columns contain values for
# the image ID ('system:index'), pixel longitude and latitude, image
# observation time ('system:time_start'), and bands. In this example, note
# that there are 5 images and the region intersects 2 pixels, so n rows
# equals 11 (5 * 2 + 1). All collection images must have the same number of
# bands with the same names.
display('Extracted pixel info', pixel_info_bbox)
# The function accepts all geometry types (e.g., points, lines, polygons).
# Here, a multi-point geometry with two points is used.
points = ee.Geometry.MultiPoint([[-90.49, 34.85], [-90.48, 34.84]])
pixel_info_points = col.getRegion(geometry=points, scale=30)
display('Point geometry example', pixel_info_points)
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\u003eImageCollection.getRegion()\u003c/code\u003e extracts pixel values from an ImageCollection for a specified region.\u003c/p\u003e\n"],["\u003cp\u003eThe output is a list of lists representing a table with pixel data, including ID, location, time, and band values.\u003c/p\u003e\n"],["\u003cp\u003eThe region can be defined using various geometries (e.g., points, lines, polygons).\u003c/p\u003e\n"],["\u003cp\u003eAll images in the collection must have the same number of bands and band names.\u003c/p\u003e\n"],["\u003cp\u003eExtracting more than 1,048,576 values will result in an error.\u003c/p\u003e\n"]]],["The `ImageCollection.getRegion` method extracts pixel values from an ImageCollection within a specified geometry. It returns a list containing rows of data for each \\[pixel, band, image\\] tuple, including id, longitude, latitude, time, and band values. Users define the extraction region, scale, and optionally the projection. The output format is a table where rows represent pixels and columns detail each image's data. The method accepts various geometry types but is limited to extracting 1,048,576 values per request.\n"],null,["# ee.ImageCollection.getRegion\n\nOutput an array of values for each \\[pixel, band, image\\] tuple in an ImageCollection. The output contains rows of id, lon, lat, time, and all bands for each image that intersects each pixel in the given region. Attempting to extract more than 1048576 values will result in an error.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------------------------------------------------------------|---------|\n| ImageCollection.getRegion`(geometry, `*scale* `, `*crs* `, `*crsTransform*`)` | List |\n\n| Argument | Type | Details |\n|--------------------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `collection` | ImageCollection | The image collection to extract data from. |\n| `geometry` | Geometry | The region over which to extract data. |\n| `scale` | Float, default: null | A nominal scale in meters of the projection to work in. |\n| `crs` | Projection, optional | The projection to work in. If unspecified, defaults to EPSG:4326. If specified in addition to scale, the projection is rescaled to the specified scale. |\n| `crsTransform` | List, default: null | The array of CRS transform values. This is a row-major ordering of a 3x2 affine transform. This option is mutually exclusive with the scale option, and will replace any transform already set on the given projection. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Landsat 8 TOA image collection (3 months at a specific point, RGB bands).\nvar col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-07-01', '2020-10-01')\n .select('B[2-4]');\nprint('Collection', col);\n\n// Define a region to get pixel values for. This is a small rectangle region\n// that intersects 2 image pixels at 30-meter scale.\nvar roi = ee.Geometry.BBox(-90.496353, 34.851971, -90.495749, 34.852197);\n\n// Display the region of interest overlaid on an image representative. Note\n// the ROI intersection with 2 pixels.\nvar visParams = {\n bands: ['B4', 'B3', 'B2'],\n min: 0.128,\n max: 0.163\n};\nMap.setCenter(-90.49605, 34.85211, 19);\nMap.addLayer(col.first(), visParams, 'Image representative');\nMap.addLayer(roi, {color: 'white'}, 'ROI');\n\n// Fetch pixel-level information from all images in the collection for the\n// pixels intersecting the ROI.\nvar pixelInfoBbox = col.getRegion({\n geometry: roi,\n scale: 30\n});\n\n// The result is a table (a list of lists) where the first row is column\n// labels and subsequent rows are image pixels. Columns contain values for\n// the image ID ('system:index'), pixel longitude and latitude, image\n// observation time ('system:time_start'), and bands. In this example, note\n// that there are 5 images and the region intersects 2 pixels, so n rows\n// equals 11 (5 * 2 + 1). All collection images must have the same number of\n// bands with the same names.\nprint('Extracted pixel info', pixelInfoBbox);\n\n// The function accepts all geometry types (e.g., points, lines, polygons).\n// Here, a multi-point geometry with two points is used.\nvar points = ee.Geometry.MultiPoint([[-90.49, 34.85], [-90.48, 34.84]]);\nvar pixelInfoPoints = col.getRegion({\n geometry: points,\n scale: 30\n});\nprint('Point geometry example', pixelInfoPoints);\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# A Landsat 8 TOA image collection (3 months at a specific point, RGB bands).\ncol = (\n ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-07-01', '2020-10-01')\n .select('B[2-4]')\n)\ndisplay('Collection', col)\n\n# Define a region to get pixel values for. This is a small rectangle region\n# that intersects 2 image pixels at 30-meter scale.\nroi = ee.Geometry.BBox(-90.496353, 34.851971, -90.495749, 34.852197)\n\n# Display the region of interest overlaid on an image representative. Note\n# the ROI intersection with 2 pixels.\nvis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.128, 'max': 0.163}\nm = geemap.Map()\nm.set_center(-90.49605, 34.85211, 19)\nm.add_layer(col.first(), vis_params, 'Image representative')\nm.add_layer(roi, {'color': 'white'}, 'ROI')\ndisplay(m)\n\n# Fetch pixel-level information from all images in the collection for the\n# pixels intersecting the ROI.\npixel_info_bbox = col.getRegion(geometry=roi, scale=30)\n\n# The result is a table (a list of lists) where the first row is column\n# labels and subsequent rows are image pixels. Columns contain values for\n# the image ID ('system:index'), pixel longitude and latitude, image\n# observation time ('system:time_start'), and bands. In this example, note\n# that there are 5 images and the region intersects 2 pixels, so n rows\n# equals 11 (5 * 2 + 1). All collection images must have the same number of\n# bands with the same names.\ndisplay('Extracted pixel info', pixel_info_bbox)\n\n# The function accepts all geometry types (e.g., points, lines, polygons).\n# Here, a multi-point geometry with two points is used.\npoints = ee.Geometry.MultiPoint([[-90.49, 34.85], [-90.48, 34.84]])\npixel_info_points = col.getRegion(geometry=points, scale=30)\ndisplay('Point geometry example', pixel_info_points)\n```"]]