Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.Number.parse

  • Useee.Number.parse(input, radix) to convert a string to anee.Number.

  • Theinput argument is the string to convert, and the optionalradix argument specifies the base number system, defaulting to 10.

  • Leading zeros are removed during the conversion process.

Convert a string to a number.

UsageReturns
ee.Number.parse(input,radix)Number
ArgumentTypeDetails
inputStringThe string to convert to a number.
radixInteger, default: 10An integer representing the base number system from which to convert. If input is not an integer, radix must equal 10 or not be specified.

Examples

Code Editor (JavaScript)

print('Client-side string converted to ee.Number',ee.Number.parse('10'));// 10print('ee.String converted to ee.Number',ee.Number.parse(ee.String('100')));// 100print('Ambiguous string object converted to ee.Number',ee.Number.parse(ee.Feature(null,{id:'1000'}).get('id')));// 1000print('Ambiguous number object converted to ee.Number',ee.Number.parse(ee.Feature(null,{id:1000}).get('id')));// 1000print('Leading zeros are removed',ee.Number.parse('0001'));// 1print('Radix 16',ee.Number.parse('3E8',16));// 1000

Python setup

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

importeeimportgeemap.coreasgeemap

Colab (Python)

display('Client-side string converted to ee.Number:',ee.Number.parse('10'))# 10display('ee.String converted to ee.Number:',ee.Number.parse(ee.String('100')))# 100# 1000display('Ambiguous string object converted to ee.Number:',ee.Number.parse(ee.Feature(None,{'id':'1000'}).get('id')))display('Leading zeros are removed:',ee.Number.parse('0001'))# 1display('Radix 16:',ee.Number.parse('3E8',16))# 1000

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.