ee.Image.select

Chọn các dải màu trong một hình ảnh.

Trả về hình ảnh có các dải tần đã chọn.

Cách sử dụngGiá trị trả về
Image.select(var_args)Hình ảnh
Đối sốLoạiThông tin chi tiết
this: imageHình ảnhĐối tượng Image.
var_argsVarArgs<Object>Một trong hai trường hợp có thể xảy ra:
  • Số lượng đối số không phải là danh sách bất kỳ. Tất cả những thông tin này sẽ được hiểu là bộ chọn dải tần. Đây có thể là tên dải tần, biểu thức chính quy hoặc chỉ mục số. Ví dụ: selected = image.select('a', 'b', 3, 'd');
  • Hai danh sách. Tham số đầu tiên sẽ được dùng làm bộ chọn dải tần và tham số thứ hai sẽ được dùng làm tên mới cho các dải tần đã chọn. Số lượng tên mới phải khớp với số lượng dải tần đã chọn. Ví dụ: selected = image.select(['a', 4], ['newA', 'newB']);

Ví dụ

Trình soạn thảo mã (JavaScript)

// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
print('All band names', img.bandNames());

print('Select a band by name',
      img.select('B11').bandNames());

print('Select a band by index',
      img.select(10).bandNames());

print('Select bands using a list',
      img.select(['B11', 'B8', 'B3']).bandNames());

print('Select bands by an argument series',
      img.select('B11', 'B8', 'B3').bandNames());

print('Mixing string and integer selectors is valid',
      img.select(10, 'B8', 2).bandNames());

print('Rename selected bands using two corresponding lists',
      img.select(['B11', 'B8', 'B3'], ['SWIR1', 'NIR', 'Green']).bandNames());

// Use regular expressions to select bands.
print('Match "QA" followed by any two characters',
      img.select('QA..').bandNames());

print('Match "B" followed by any character, any number of times',
      img.select('B.*').bandNames());

print('Match "B" followed by any character, and any optional third character',
      img.select('B..?').bandNames());

print('Match "B" followed by a character in the range 6-8',
      img.select('B[6-8]').bandNames());

print('Match "B" followed by a character in the range 1-9 and then 1-2',
      img.select('B[1-9][1-2]').bandNames());

print('Match "B" or "QA" each followed by any character, any number of times.',
      img.select('B.*|QA.*').bandNames());

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

import ee
import geemap.core as geemap

Colab (Python)

# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
print('All band names:', img.bandNames().getInfo())

print('Select a band by name:', img.select('B11').bandNames().getInfo())

print('Select a band by index:', img.select(10).bandNames().getInfo())

print('Select bands using a list:',
      img.select(['B11', 'B8', 'B3']).bandNames().getInfo())

print('Select bands by an argument series:',
      img.select('B11', 'B8', 'B3').bandNames().getInfo())

print('Mixing string and integer selectors is valid:',
      img.select(10, 'B8', 2).bandNames().getInfo())

print('Rename selected bands using two corresponding lists:',
      img.select(['B11', 'B8', 'B3'], ['SWIR1', 'NIR', 'Green'])
      .bandNames().getInfo())

# Use regular expressions to select bands.
print('Match "QA" followed by any two characters:',
      img.select('QA..').bandNames().getInfo())

print('Match "B" followed by any character, any number of times:',
      img.select('B.*').bandNames().getInfo())

print('Match "B" followed by any character, and any optional third character',
      img.select('B..?').bandNames().getInfo())

print('Match "B" followed by a character in the range 6-8',
      img.select('B[6-8]').bandNames().getInfo())

print('Match "B" followed by a character in the range 1-9 and then 1-2',
      img.select('B[1-9][1-2]').bandNames().getInfo())

print('Match "B" or "QA" each followed by any character, any number of times.',
      img.select('B.*|QA.*').bandNames().getInfo())