ee.List.sequence
Generate a sequence of numbers from start to end (inclusive) in increments of step, or in count equally-spaced increments. If end is not specified it is computed from start + step * count, so at least one of end or count must be specified.
Usage | Returns |
---|
ee.List.sequence(start, end, step, count) | List |
Argument | Type | Details |
---|
start | Number | The starting number. |
end | Number, default: null | The ending number. |
step | Number, default: 1 | The increment. |
count | Integer, default: null | The number of increments. |
Examples
print(ee.List.sequence(0, 5)); // [0,1,2,3,4,5]
print(ee.List.sequence(0, 10, 2)); // [0,2,4,6,8,10]
print(ee.List.sequence(0, null, 2, 6)); // [0,2,4,6,8,10]
print(ee.List.sequence(0, null, -2, 6)); // [0,-2,-4,-6,-8,-10]
// Step ignored when present along with count.
print(ee.List.sequence(0, 10, 2, 999)); // 999 elements
print(ee.List.sequence(0, 10, 2, 3)); // [0,5,10]
// Using a dictionary for arguments.
print(ee.List.sequence({start:10, count:3})); // [10,11,12]
print(ee.List.sequence({start:3, step:2, end:6})); // [3,5]
// [-1000000000,0,1000000000]
print(ee.List.sequence({start:-1e9, end:1e9, count:3}));
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
print(ee.List.sequence(0, 5).getInfo()) # [0, 1, 2, 3, 4, 5]
print(ee.List.sequence(0, 10, 2).getInfo()) # [0, 2, 4, 6, 8, 10]
print(ee.List.sequence(0, None, 2, 6).getInfo()) # [0, 2, 4, 6, 8, 10]
print(ee.List.sequence(0, None, -2, 6).getInfo()) # [0, -2, -4, -6, -8, -10]
# Step ignored when present along with count.
print(ee.List.sequence(0, 10, 2, 999).getInfo()) # 999 elements
print(ee.List.sequence(0, 10, 2, 3).getInfo()) # [0, 5, 10]
# Using a dictionary for arguments.
print(ee.List.sequence(start=10, count=3).getInfo()) # [10, 11, 12]
print(ee.List.sequence(start=3, step=2, end=6).getInfo()) # [3, 5]
# [-1000000000, 0, 1000000000]
print(ee.List.sequence(start=-1e9, end=1e9, count=3).getInfo())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-13 UTC.
[null,null,["Last updated 2024-07-13 UTC."],[[["`ee.List.sequence` generates a list of numbers within a specified range, determined by `start`, `end`, `step`, and `count` parameters."],["You must define either the `end` or `count` parameter alongside the `start` parameter to determine the sequence range."],["The `step` parameter defines the increment between numbers in the sequence and defaults to 1 if not specified."],["When both `step` and `count` are specified, `step` is ignored and the sequence is divided into equally spaced increments based on `count`."],["You can provide arguments as a dictionary using keys like `start`, `end`, `step`, and `count` for better readability."]]],[]]