MCPcopy
hub / github.com/google/earthengine-api / select

Method select

python/ee/image.py:3898–3958  ·  view source on GitHub ↗

Selects bands from an image. Can be called in one of two ways: - Passed any number of non-list arguments. All of these will be interpreted as band selectors. These can be band names, regexes, or numeric indices. For example: selected = image.select('a', 'b', 3, 'd'

(
      self,
      selectors: _arg_types.List | None = None,
      names: _arg_types.List | None = None,
      *args,
  )

Source from the content-addressed store, hash-verified

3896 @_utils.accept_opt_prefix('opt_selectors', 'opt_names')
3897 # pylint: disable-next=keyword-arg-before-vararg
3898 def select(
3899 self,
3900 selectors: _arg_types.List | None = None,
3901 names: _arg_types.List | None = None,
3902 *args,
3903 ) -> Image:
3904 """Selects bands from an image.
3905
3906 Can be called in one of two ways:
3907 - Passed any number of non-list arguments. All of these will be
3908 interpreted as band selectors. These can be band names, regexes, or
3909 numeric indices. For example:
3910 selected = image.select('a', 'b', 3, 'd');
3911 - Passed two lists. The first will be used as band selectors and the
3912 second as new names for the selected bands. The number of new names
3913 must match the number of selected bands. For example:
3914 selected = image.select(['a', 4], ['newA', 'newB']);
3915
3916 Args:
3917 selectors: An array of names, regexes or numeric indices specifying the
3918 bands to select.
3919 names: An array of strings specifying the new names for the selected
3920 bands.
3921 *args: Selector elements as varargs.
3922
3923 Returns:
3924 An image with the selected bands.
3925 """
3926 if selectors is not None:
3927 args = list(args)
3928 if names is not None:
3929 args.insert(0, names)
3930 args.insert(0, selectors)
3931 algorithm_args = {
3932 'input': self,
3933 'bandSelectors': args[0] if args else [],
3934 }
3935 if args:
3936 # If the user didn't pass an array as the first argument, assume
3937 # that everything in the arguments array is actually a selector.
3938 if (
3939 len(args) > 2
3940 or ee_types.isString(args[0])
3941 or ee_types.isNumber(args[0])
3942 ):
3943 # Varargs inputs.
3944 selectors = args
3945 # Verify we didn't get anything unexpected.
3946 for selector in selectors:
3947 if (
3948 not ee_types.isString(selector)
3949 and not ee_types.isNumber(selector)
3950 and not isinstance(selector, computedobject.ComputedObject)
3951 ):
3952 raise ee_exception.EEException(
3953 'Illegal argument to select(): ' + selector
3954 )
3955 algorithm_args['bandSelectors'] = selectors

Callers 15

_build_image_per_bandMethod · 0.95
combine_Method · 0.95
where.pyFile · 0.45
hdr_landsat.pyFile · 0.45
hsv_pan_sharpen.pyFile · 0.45
hillshade.pyFile · 0.45
SAVIFunction · 0.45
test_mappingMethod · 0.45
test_selectMethod · 0.45

Calls 2

insertMethod · 0.80
apply_Method · 0.80

Tested by 7

test_mappingMethod · 0.36
test_selectMethod · 0.36
test_selectMethod · 0.36
test_selectMethod · 0.36
test_selectMethod · 0.36