Introductory Example

Now that you’ve installed the Python client and tested the connection, you can start using the Platform. This example shows the core interaction with the Platform: searching for imagery and loading it.

$ pip install "descarteslabs[complete]"
$ descarteslabs auth login
import descarteslabs as dl
>>> import numpy as np
>>>
>>> sangre_de_cristo_geojson = {
...     "type": "Polygon",
...     "coordinates": [[
...         [-106, 35.5], [-105, 35.5], [-105, 36.5], [-106, 36.5], [-106, 35.5]
...     ]]
... }
...
>>> scenes, geoctx = dl.scenes.search(
...     sangre_de_cristo_geojson,
...     products=["sentinel-2:L1C", "landsat:LC08:01:T1:TOAR"],
...     start_datetime="2016-12-01",
...     end_datetime="2018-03-01",
...     cloud_fraction=0.1,
... )
...
>>> winter_scenes = scenes.filter(
...     lambda scene: scene.properties.date.month in [12, 1, 2]
... )
...
>>> winter_scenes
SceneCollection of 42 scenes
  * Dates: Dec 03, 2016 to Feb 12, 2018
  * Products: landsat:LC08:01:T1:TOAR: 29, sentinel-2:L1C: 13
>>>
>>> ndarray_stack = winter_scenes.stack(
...     "red green blue",
...     geoctx.assign(resolution=150)
... )
...
>>> ndarray_stack.shape
(42, 3, 737, 606)
>>>
>>> winter_composite = np.ma.median(ndarray_stack, axis=0)
>>>
>>> dl.scenes.display(winter_composite, title="Median composite of winter Sange de Cristo range 2016-2018", size=6)
https://cdn.descarteslabs.com/docs/public/_images/introductory-example_figure3_1.png