공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
ee.Number.format
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
printf 스타일 형식을 사용하여 숫자를 문자열로 변환합니다.
사용 | 반환 값 |
---|
Number.format(pattern) | 문자열 |
인수 | 유형 | 세부정보 |
---|
다음과 같은 경우: number | 숫자 | 문자열로 변환할 숫자입니다. |
pattern | 문자열, 기본값: '%s' | printf 스타일 형식 문자열입니다. 예를 들어 '%.2f'는 '3.14'와 같이 형식이 지정된 숫자를 생성하고 '%05d'는 '00042'와 같이 형식이 지정된 숫자를 생성합니다. 형식 문자열은 다음 기준을 충족해야 합니다.
- 0개 이상의 접두사 문자입니다.
- '%'가 정확히 하나 있습니다.
- [#-+ 0,(.\d] 집합에 있는 0개 이상의 수정자 문자
- [sdoxXeEfgGaA] 집합에 정확히 하나의 변환 문자가 있습니다.
- 0개 이상의 접미사 문자입니다.
형식 문자열에 대한 자세한 내용은 https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html을 참고하세요. |
예
코드 편집기 (JavaScript)
print('Zero-fill to length of 3',
ee.Number(1).format('%03d')); // 001
print('Include 1 decimal place in 1.2347',
ee.Number(1.23476).format('%.1f')); // 1.2
print('Include 3 decimal places in 1.2347',
ee.Number(1.23476).format('%.3f')); // 1.235 (rounds up)
print('Scientific notation with 3 decimal places shown',
ee.Number(123476).format('%.3e')); // 1.235e+05 (rounds up)
print('Integer with 2 decimal places of precision',
ee.Number(123476).format('%.2f')); // 123476.00
Python 설정
Python API 및 geemap
를 사용한 대화형 개발에 관한 자세한 내용은
Python 환경 페이지를 참고하세요.
import ee
import geemap.core as geemap
Colab (Python)
print('Zero-fill to length of 3:',
ee.Number(1).format('%03d').getInfo()) # 001
print('Include 1 decimal place in 1.2347:',
ee.Number(1.23476).format('%.1f').getInfo()) # 1.2
print('Include 3 decimal places in 1.2347:',
ee.Number(1.23476).format('%.3f').getInfo()) # 1.235 (rounds up)
print('Scientific notation with 3 decimal places shown:',
ee.Number(123476).format('%.3e').getInfo()) # 1.235e+05 (rounds up)
print('Integer with 2 decimal places of precision:',
ee.Number(123476).format('%.2f').getInfo()) # 123476.00
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003eNumber.format()\u003c/code\u003e converts Earth Engine Numbers to strings using printf-style formatting.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epattern\u003c/code\u003e argument accepts a format string, like '%.2f' for 2 decimal places or '%03d' for zero-padding to 3 digits.\u003c/p\u003e\n"],["\u003cp\u003eThis function allows customization of numeric output for display or further processing within Earth Engine scripts.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the Java Formatter documentation for details on available format string options and syntax.\u003c/p\u003e\n"]]],[],null,["# ee.Number.format\n\nConvert a number to a string using printf-style formatting.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------|---------|\n| Number.format`(`*pattern*`)` | String |\n\n| Argument | Type | Details |\n|----------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `number` | Number | The number to convert to a string. |\n| `pattern` | String, default: \"%s\" | A printf-style format string. For example, '%.2f' produces numbers formatted like '3.14', and '%05d' produces numbers formatted like '00042'. The format string must satisfy the following criteria: 1. Zero or more prefix characters. 2. Exactly one '%'. 3. Zero or more modifier characters in the set \\[#-+ 0,(.\\\\d\\]. 4. Exactly one conversion character in the set \\[sdoxXeEfgGaA\\]. 5. Zero or more suffix characters. For more about format strings, see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint('Zero-fill to length of 3',\n ee.Number(1).format('%03d')); // 001\n\nprint('Include 1 decimal place in 1.2347',\n ee.Number(1.23476).format('%.1f')); // 1.2\n\nprint('Include 3 decimal places in 1.2347',\n ee.Number(1.23476).format('%.3f')); // 1.235 (rounds up)\n\nprint('Scientific notation with 3 decimal places shown',\n ee.Number(123476).format('%.3e')); // 1.235e+05 (rounds up)\n\nprint('Integer with 2 decimal places of precision',\n ee.Number(123476).format('%.2f')); // 123476.00\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nprint('Zero-fill to length of 3:',\n ee.Number(1).format('%03d').getInfo()) # 001\n\nprint('Include 1 decimal place in 1.2347:',\n ee.Number(1.23476).format('%.1f').getInfo()) # 1.2\n\nprint('Include 3 decimal places in 1.2347:',\n ee.Number(1.23476).format('%.3f').getInfo()) # 1.235 (rounds up)\n\nprint('Scientific notation with 3 decimal places shown:',\n ee.Number(123476).format('%.3e').getInfo()) # 1.235e+05 (rounds up)\n\nprint('Integer with 2 decimal places of precision:',\n ee.Number(123476).format('%.2f').getInfo()) # 123476.00\n```"]]