ee.ImageCollection.getRegion

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.

UsoMuestra
ImageCollection.getRegion(geometry, scale, crs, crsTransform)Lista
ArgumentoTipoDetalles
esta: collectionImageCollectionEs la colección de imágenes de la que se extraerán los datos.
geometryGeometríaEs la región para la que se extraerán los datos.
scaleNúmero de punto flotante, valor predeterminado: nuloEs una escala nominal en metros de la proyección en la que se trabajará.
crsProyecció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.
crsTransformLista, valor predeterminado: nullEs 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)