ee.String.length

  • String.length() is a method that returns the number of characters in a string as an integer.

  • The method takes one argument: the input string for which to determine the length.

  • Examples demonstrate its usage in both JavaScript and Python within the Earth Engine environment.

Returns the length of a string.

UsageReturns
String.length()Integer
ArgumentTypeDetails
this: stringStringThe string from which to get the length.

Examples

Code Editor (JavaScript)

print(ee.String('').length());  // 0
print(ee.String('abc123').length());  // 6

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

print(ee.String('').length().getInfo())  # 0
print(ee.String('abc123').length().getInfo())  # 6