Note
You can run this notebook interactively: , or view & download the original on GitHub.
Stacking 6 years of imagery into a GIF¶
We’ll load all the Landsat-8 (Collection 2, Level 2) data that’s available from Microsoft’s Planetary Computer over a small region on the coast of Cape Cod, Massachusetts, USA.
Using nothing but standard xarray syntax, we’ll mask cloudy pixels with the Landsat QA band and reduce the data down to biannual median composites.
Animated as a GIF, we can watch the coastline move over the years due to longshore drift.
Planetary Computer is Microsoft’s open Earth data initiative. It’s particularly nice to use, since they also maintain a STAC API for searching all the data, as well as a browseable data catalog. It’s free for anyone to use, though you have to sign your requests with the planetary_computer
package to
prevent abuse. If you sign up, you’ll get faster reads.
[1]:
import coiled
import distributed
import dask
import pystac_client
import planetary_computer as pc
import ipyleaflet
import IPython.display as dsp
import geogif
import stackstac
Using a cluster will make this much faster. Particularly if you’re not in Europe, which is where this data is stored.
You can sign up for a Coiled account and run clusters for free at https://cloud.coiled.io/ — no credit card or username required, just sign in with your GitHub or Google account.
[2]:
cluster = coiled.Cluster(
name="stackstac-eu",
software="gjoseph92/stackstac",
backend_options={"region": "eu-central-1"},
# ^ Coiled doesn't yet support Azure's West Europe region, so instead we'll run on a nearby AWS data center in Frankfurt
n_workers=20,
protocol="wss", # remove this line when not running on Binder
)
client = distributed.Client(cluster)
client
Using existing cluster: 'stackstac-eu'
[2]:
Client
Client-e79eb2e6-5268-11ec-9843-acde48001122
Connection method: Cluster object | Cluster type: coiled.Cluster |
Dashboard: http://18.184.228.92:8787 |
Cluster Info
Cluster
stackstac-eu
Dashboard: http://18.184.228.92:8787 | Workers: 20 |
Total threads: 40 | Total memory: 149.63 GiB |
Scheduler Info
Scheduler
Scheduler-43919015-e552-493d-8622-1e6a83519700
Comm: tls://10.13.5.99:8786 | Workers: 20 |
Dashboard: http://10.13.5.99:8787/status | Total threads: 40 |
Started: 4 minutes ago | Total memory: 149.63 GiB |
Workers
Worker: coiled-dask-gjosephf7-74123-worker-0c42b153ab
Comm: tls://10.13.26.236:45919 | Total threads: 2 |
Dashboard: http://10.13.26.236:44045/status | Memory: 7.48 GiB |
Nanny: tls://10.13.26.236:36315 | |
Local directory: /dask-worker-space/worker-sq7hgz28 |
Worker: coiled-dask-gjosephf7-74123-worker-17b014abd2
Comm: tls://10.13.22.52:39709 | Total threads: 2 |
Dashboard: http://10.13.22.52:32969/status | Memory: 7.48 GiB |
Nanny: tls://10.13.22.52:34365 | |
Local directory: /dask-worker-space/worker-7ai5ugu_ |
Worker: coiled-dask-gjosephf7-74123-worker-2324d4e10d
Comm: tls://10.13.25.13:39927 | Total threads: 2 |
Dashboard: http://10.13.25.13:42769/status | Memory: 7.48 GiB |
Nanny: tls://10.13.25.13:44815 | |
Local directory: /dask-worker-space/worker-o6772g1v |
Worker: coiled-dask-gjosephf7-74123-worker-2dcad8404e
Comm: tls://10.13.28.65:42527 | Total threads: 2 |
Dashboard: http://10.13.28.65:36167/status | Memory: 7.48 GiB |
Nanny: tls://10.13.28.65:37809 | |
Local directory: /dask-worker-space/worker-__u6hb_a |
Worker: coiled-dask-gjosephf7-74123-worker-46e5582adc
Comm: tls://10.13.23.81:36365 | Total threads: 2 |
Dashboard: http://10.13.23.81:45767/status | Memory: 7.48 GiB |
Nanny: tls://10.13.23.81:43191 | |
Local directory: /dask-worker-space/worker-m6hug4on |
Worker: coiled-dask-gjosephf7-74123-worker-4e8c77e790
Comm: tls://10.13.24.82:43501 | Total threads: 2 |
Dashboard: http://10.13.24.82:45765/status | Memory: 7.48 GiB |
Nanny: tls://10.13.24.82:43945 | |
Local directory: /dask-worker-space/worker-chovpf_0 |
Worker: coiled-dask-gjosephf7-74123-worker-550582ff4f
Comm: tls://10.13.27.175:44383 | Total threads: 2 |
Dashboard: http://10.13.27.175:42385/status | Memory: 7.48 GiB |
Nanny: tls://10.13.27.175:33297 | |
Local directory: /dask-worker-space/worker-8o7438z3 |
Worker: coiled-dask-gjosephf7-74123-worker-5bb2c8aa22
Comm: tls://10.13.18.33:41607 | Total threads: 2 |
Dashboard: http://10.13.18.33:43489/status | Memory: 7.48 GiB |
Nanny: tls://10.13.18.33:41867 | |
Local directory: /dask-worker-space/worker-j19xrdlx |
Worker: coiled-dask-gjosephf7-74123-worker-6f290f89da
Comm: tls://10.13.17.73:40157 | Total threads: 2 |
Dashboard: http://10.13.17.73:34485/status | Memory: 7.48 GiB |
Nanny: tls://10.13.17.73:35229 | |
Local directory: /dask-worker-space/worker-tdycdi0z |
Worker: coiled-dask-gjosephf7-74123-worker-7038e5a52d
Comm: tls://10.13.28.5:40691 | Total threads: 2 |
Dashboard: http://10.13.28.5:37155/status | Memory: 7.48 GiB |
Nanny: tls://10.13.28.5:38403 | |
Local directory: /dask-worker-space/worker-bl_hqx1q |
Worker: coiled-dask-gjosephf7-74123-worker-8386f113c2
Comm: tls://10.13.30.215:39281 | Total threads: 2 |
Dashboard: http://10.13.30.215:37727/status | Memory: 7.48 GiB |
Nanny: tls://10.13.30.215:37239 | |
Local directory: /dask-worker-space/worker-0onhlf9_ |
Worker: coiled-dask-gjosephf7-74123-worker-92bf25df55
Comm: tls://10.13.19.155:36683 | Total threads: 2 |
Dashboard: http://10.13.19.155:42811/status | Memory: 7.48 GiB |
Nanny: tls://10.13.19.155:36411 | |
Local directory: /dask-worker-space/worker-5yxpubpw |
Worker: coiled-dask-gjosephf7-74123-worker-968ece0ee5
Comm: tls://10.13.26.183:41177 | Total threads: 2 |
Dashboard: http://10.13.26.183:46093/status | Memory: 7.48 GiB |
Nanny: tls://10.13.26.183:35367 | |
Local directory: /dask-worker-space/worker-l62hk_35 |
Worker: coiled-dask-gjosephf7-74123-worker-a42afc05f4
Comm: tls://10.13.19.85:42139 | Total threads: 2 |
Dashboard: http://10.13.19.85:40123/status | Memory: 7.48 GiB |
Nanny: tls://10.13.19.85:34353 | |
Local directory: /dask-worker-space/worker-3_le7umx |
Worker: coiled-dask-gjosephf7-74123-worker-cc1795452b
Comm: tls://10.13.19.98:33873 | Total threads: 2 |
Dashboard: http://10.13.19.98:38859/status | Memory: 7.48 GiB |
Nanny: tls://10.13.19.98:45565 | |
Local directory: /dask-worker-space/worker-itsco188 |
Worker: coiled-dask-gjosephf7-74123-worker-d48798bbee
Comm: tls://10.13.22.217:39139 | Total threads: 2 |
Dashboard: http://10.13.22.217:45845/status | Memory: 7.48 GiB |
Nanny: tls://10.13.22.217:36979 | |
Local directory: /dask-worker-space/worker-c50bcq23 |
Worker: coiled-dask-gjosephf7-74123-worker-eb8c0be115
Comm: tls://10.13.16.18:37211 | Total threads: 2 |
Dashboard: http://10.13.16.18:33465/status | Memory: 7.48 GiB |
Nanny: tls://10.13.16.18:43579 | |
Local directory: /dask-worker-space/worker-ccvgs568 |
Worker: coiled-dask-gjosephf7-74123-worker-ecaf57c00c
Comm: tls://10.13.20.129:34971 | Total threads: 2 |
Dashboard: http://10.13.20.129:43601/status | Memory: 7.48 GiB |
Nanny: tls://10.13.20.129:45277 | |
Local directory: /dask-worker-space/worker-9j9b8in_ |
Worker: coiled-dask-gjosephf7-74123-worker-f08705ce76
Comm: tls://10.13.20.19:46285 | Total threads: 2 |
Dashboard: http://10.13.20.19:41733/status | Memory: 7.56 GiB |
Nanny: tls://10.13.20.19:41531 | |
Local directory: /dask-worker-space/worker-je_p_ard |
Worker: coiled-dask-gjosephf7-74123-worker-f1a5e468b2
Comm: tls://10.13.28.171:38199 | Total threads: 2 |
Dashboard: http://10.13.28.171:42099/status | Memory: 7.48 GiB |
Nanny: tls://10.13.28.171:46121 | |
Local directory: /dask-worker-space/worker-552g8oo_ |
Interactively pick the area of interest from a map. Just move the map around and re-run all cells to generate the timeseries somewhere else!
[3]:
m = ipyleaflet.Map(scroll_wheel_zoom=True)
m.center = 41.64933994767867, -69.94438630063088
m.zoom = 12
m.layout.height = "800px"
m
[4]:
bbox = (m.west, m.south, m.east, m.north)
Search for STAC items¶
Use pystac-client to connect to Microsoft’s STAC API endpoint and search for Landsat-8 scenes.
[5]:
catalog = pystac_client.Client.open('https://planetarycomputer.microsoft.com/api/stac/v1')
search = catalog.search(
collections=['landsat-8-c2-l2'],
bbox=bbox,
)
Load and sign all the STAC items with a token from Planetary Computer. Without this, loading the data will fail.
[6]:
%%time
items = pc.sign(search)
len(items)
CPU times: user 584 ms, sys: 41.1 ms, total: 625 ms
Wall time: 7.03 s
[6]:
375
These are the footprints of all the items we’ll use:
[7]:
dsp.GeoJSON(items.to_dict())
<IPython.display.GeoJSON object>
Create an xarray with stacksatc¶
Set bounds_latlon=bbox
to automatically clip to our area of interest (instead of using the full footprints of the scenes).
[8]:
%%time
stack = stackstac.stack(items, bounds_latlon=bbox)
stack
CPU times: user 311 ms, sys: 10.5 ms, total: 321 ms
Wall time: 319 ms
[8]:
<xarray.DataArray 'stackstac-bae570f2cbe4987fda83bcd5371b5a40' (time: 375, band: 19, y: 773, x: 1158)> dask.array<fetch_raster_window, shape=(375, 19, 773, 1158), dtype=float64, chunksize=(1, 1, 773, 1024), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2013-03-22T15:19:00.54... id (time) <U31 'LC08_L2SP_011031_20130322_02_T1... * band (band) <U13 'SR_B1' 'SR_B2' ... 'SR_QA_AEROSOL' * x (x) float64 4.04e+05 4.04e+05 ... 4.387e+05 * y (y) float64 4.623e+06 4.623e+06 ... 4.6e+06 proj:epsg int64 32619 instruments object {'tirs', 'oli'} view:sun_elevation (time) float64 44.94 50.04 51.92 ... 29.5 27.64 landsat:collection_category (time) <U2 'T1' 'T1' 'T1' ... 'T1' 'T1' 'T1' landsat:scene_id (time) <U21 'LC80110312013081LGN02' ... 'LC8... view:sun_azimuth (time) float64 149.6 148.3 ... 163.0 163.2 description (band) <U91 'Collection 2 Level-2 Coastal/Ae... landsat:wrs_path (time) <U3 '011' '012' '012' ... '011' '012' platform <U9 'landsat-8' eo:cloud_cover (time) float64 92.94 0.77 11.81 ... 0.07 1.59 landsat:wrs_type <U1 '2' landsat:cloud_cover_land (time) float64 90.98 1.51 15.5 ... 0.54 2.08 landsat:wrs_row <U3 '031' landsat:collection_number <U2 '02' landsat:processing_level <U4 'L2SP' view:off_nadir int64 0 gsd (band) float64 30.0 30.0 30.0 ... 30.0 30.0 title (band) <U46 'Coastal/Aerosol Band (B1)' ... ... common_name (band) object 'coastal' 'blue' ... None None center_wavelength (band) object 0.44 0.48 0.56 ... None None None full_width_half_max (band) object 0.02 0.06 0.06 ... None None None epsg int64 32619 Attributes: spec: RasterSpec(epsg=32619, bounds=(403980.0, 4599690.0, 438720.0... crs: epsg:32619 transform: | 30.00, 0.00, 403980.00|\n| 0.00,-30.00, 4622880.00|\n| 0.0... resolution: 30.0
- time: 375
- band: 19
- y: 773
- x: 1158
- dask.array<chunksize=(1, 1, 773, 1024), meta=np.ndarray>
Array Chunk Bytes 47.52 GiB 6.04 MiB Shape (375, 19, 773, 1158) (1, 1, 773, 1024) Count 28502 Tasks 14250 Chunks Type float64 numpy.ndarray 375 1 1158 773 19 - time(time)datetime64[ns]2013-03-22T15:19:00.545659 ... 2...
array(['2013-03-22T15:19:00.545659000', '2013-04-04T15:27:44.408822000', '2013-04-09T15:27:54.193621000', ..., '2021-10-31T15:27:32.442147000', '2021-11-09T15:21:19.257057000', '2021-11-16T15:27:27.116402000'], dtype='datetime64[ns]')
- id(time)<U31'LC08_L2SP_011031_20130322_02_T1...
array(['LC08_L2SP_011031_20130322_02_T1', 'LC08_L2SP_012031_20130404_02_T1', 'LC08_L2SP_012031_20130409_02_T1', 'LC08_L2SP_012031_20130416_02_T1', 'LC08_L2SP_012031_20130502_02_T1', 'LC08_L2SP_011031_20130511_02_T1', 'LC08_L2SP_012031_20130518_02_T1', 'LC08_L2SP_011031_20130527_02_T1', 'LC08_L2SP_012031_20130603_02_T2', 'LC08_L2SP_012031_20130619_02_T1', 'LC08_L2SP_011031_20130628_02_T2', 'LC08_L2SP_012031_20130705_02_T1', 'LC08_L2SP_011031_20130714_02_T1', 'LC08_L2SP_012031_20130721_02_T1', 'LC08_L2SP_011031_20130730_02_T1', 'LC08_L2SP_012031_20130806_02_T1', 'LC08_L2SP_011031_20130815_02_T1', 'LC08_L2SP_012031_20130822_02_T1', 'LC08_L2SP_011031_20130831_02_T1', 'LC08_L2SP_012031_20130907_02_T1', ... 'LC08_L2SP_011031_20210618_02_T1', 'LC08_L2SP_012031_20210625_02_T2', 'LC08_L2SP_011031_20210704_02_T2', 'LC08_L2SP_012031_20210711_02_T1', 'LC08_L2SP_011031_20210720_02_T1', 'LC08_L2SP_012031_20210727_02_T1', 'LC08_L2SP_011031_20210805_02_T2', 'LC08_L2SP_012031_20210812_02_T1', 'LC08_L2SP_011031_20210821_02_T1', 'LC08_L2SP_012031_20210828_02_T1', 'LC08_L2SP_011031_20210906_02_T1', 'LC08_L2SP_012031_20210913_02_T1', 'LC08_L2SP_011031_20210922_02_T1', 'LC08_L2SP_012031_20210929_02_T1', 'LC08_L2SP_011031_20211008_02_T1', 'LC08_L2SP_012031_20211015_02_T1', 'LC08_L2SP_011031_20211024_02_T1', 'LC08_L2SP_012031_20211031_02_T1', 'LC08_L2SP_011031_20211109_02_T1', 'LC08_L2SP_012031_20211116_02_T1'], dtype='<U31')
- band(band)<U13'SR_B1' 'SR_B2' ... 'SR_QA_AEROSOL'
array(['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7', 'ST_QA', 'ST_B10', 'ST_DRAD', 'ST_EMIS', 'ST_EMSD', 'ST_TRAD', 'ST_URAD', 'QA_PIXEL', 'ST_ATRAN', 'ST_CDIST', 'QA_RADSAT', 'SR_QA_AEROSOL'], dtype='<U13')
- x(x)float644.04e+05 4.04e+05 ... 4.387e+05
array([403980., 404010., 404040., ..., 438630., 438660., 438690.])
- y(y)float644.623e+06 4.623e+06 ... 4.6e+06
array([4622880., 4622850., 4622820., ..., 4599780., 4599750., 4599720.])
- proj:epsg()int6432619
array(32619)
- instruments()object{'tirs', 'oli'}
array({'tirs', 'oli'}, dtype=object)
- view:sun_elevation(time)float6444.94 50.04 51.92 ... 29.5 27.64
array([44.94417071, 50.03688029, 51.91632915, 54.41131525, 59.40718374, 61.6556255 , 63.07418224, 64.43888487, 65.13444578, 65.55535015, 65.14954169, 64.55106938, 63.45818749, 62.38129249, 60.7259742 , 59.2360822 , 57.08116314, 55.22892055, 52.63960694, 50.47736556, 47.54839298, 45.17739203, 42.05985671, 36.51448601, 31.33641965, 29.30304958, 26.99128606, 25.4692469 , 23.93148476, 22.52691318, 22.98414564, 23.77791608, 25.29993771, 29.2553281 , 31.41001757, 34.47053286, 37.02887416, 40.46582911, 46.72449765, 52.72170122, 57.94968345, 61.94545945, 63.2550021 , 64.44792066, 65.01188877, 65.2859204 , 65.16968217, 64.63613449, 63.95535596, 62.7746641 , 61.63358442, 59.9030512 , 58.36487079, 56.15327755, 54.2573929 , 51.62087626, 49.43339573, 46.47909572, 44.095653 , 40.98096133, 38.55270431, 35.48977112, 33.19446095, 30.43494534, 28.47986937, 26.28658186, 24.87144921, 23.4905364 , 22.7873144 , 22.39498089, 22.50321376, 23.17627819, 24.10642545, 25.79187975, 27.4578998 , 32.23510075, 35.38106331, 37.98843546, 41.46217367, 44.20978811, 47.71627192, 50.37402799, 53.62036853, 58.66969931, 62.44795416, 63.61521835, 64.64864251, 65.09087471, 65.21437718, 64.99282172, 64.34433852, 63.58119259, 62.30094448, 61.09216398, 59.28361053, 57.68336158, 55.39548415, 53.44933689, 50.7554881 , 48.52670782, ... 58.88406639, 56.73774443, 54.8900685 , 52.30738256, 50.15303823, 47.23598858, 44.87313193, 41.76571725, 39.33293321, 36.24925576, 33.92395458, 31.10309232, 29.08917462, 26.80222699, 25.30102211, 23.79368444, 22.9844411 , 22.44959394, 22.44221807, 22.96943006, 23.7894223 , 25.34485821, 26.91687549, 29.35179125, 31.52492038, 34.6049865 , 37.17571768, 40.62377703, 43.36717767, 46.88765574, 49.57374914, 52.87421508, 58.0733433 , 62.06345985, 63.33101929, 64.4930502 , 65.03481102, 65.27959198, 65.14129066, 64.58738906, 63.8921047 , 62.69209778, 61.53639053, 59.79414255, 58.2446115 , 56.01759531, 54.11064638, 51.46570481, 49.26927073, 46.3051155 , 43.91847047, 40.80345206, 38.37588833, 35.31625681, 33.0308533 , 26.17516599, 24.78409761, 23.43425605, 22.75692163, 22.40174678, 22.54022423, 23.25047467, 24.20774447, 25.9291269 , 27.61839864, 30.18330532, 32.44065724, 35.60646289, 38.22322897, 41.70587965, 44.456239 , 47.96101262, 50.61426932, 53.84868612, 58.86639313, 60.69436524, 62.61497657, 63.76009737, 64.76139035, 65.17846013, 65.27223078, 65.0310067 , 64.35614877, 63.57254714, 62.27136981, 61.04664145, 59.21514756, 57.59715835, 55.29254678, 53.33189574, 50.61963618, 48.37857161, 45.3771016 , 42.97228493, 39.84688448, 37.42808639, 34.40746637, 32.16598462, 29.49837575, 27.63990895])
- landsat:collection_category(time)<U2'T1' 'T1' 'T1' ... 'T1' 'T1' 'T1'
array(['T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T2', 'T1', 'T2', 'T2', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T2', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T2', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1'], dtype='<U2')
- landsat:scene_id(time)<U21'LC80110312013081LGN02' ... 'LC8...
array(['LC80110312013081LGN02', 'LC80120312013094LGN02', 'LC80120312013099LGN02', 'LC80120312013106LGN03', 'LC80120312013122LGN02', 'LC80110312013131LGN02', 'LC80120312013138LGN02', 'LC80110312013147LGN01', 'LC80120312013154LGN01', 'LC80120312013170LGN01', 'LC80110312013179LGN01', 'LC80120312013186LGN01', 'LC80110312013195LGN01', 'LC80120312013202LGN01', 'LC80110312013211LGN01', 'LC80120312013218LGN01', 'LC80110312013227LGN01', 'LC80120312013234LGN01', 'LC80110312013243LGN01', 'LC80120312013250LGN01', 'LC80110312013259LGN01', 'LC80120312013266LGN01', 'LC80110312013275LGN01', 'LC80110312013291LGN01', 'LC80110312013307LGN01', 'LC80120312013314LGN01', 'LC80110312013323LGN01', 'LC80120312013330LGN01', 'LC80110312013339LGN04', 'LC80110312013355LGN02', 'LC80110312014006LGN01', 'LC80120312014013LGN01', 'LC80110312014022LGN01', 'LC80110312014038LGN01', 'LC80120312014045LGN01', 'LC80110312014054LGN01', 'LC80120312014061LGN03', 'LC80110312014070LGN01', 'LC80110312014086LGN01', 'LC80110312014102LGN01', ... 'LC80110312021009LGN00', 'LC80120312021016LGN00', 'LC80110312021025LGN00', 'LC80120312021032LGN00', 'LC80110312021041LGN00', 'LC80120312021048LGN00', 'LC80110312021057LGN00', 'LC80120312021064LGN00', 'LC80110312021073LGN00', 'LC80120312021080LGN00', 'LC80110312021089LGN00', 'LC80120312021096LGN00', 'LC80110312021105LGN00', 'LC80110312021121LGN00', 'LC80120312021128LGN00', 'LC80110312021137LGN00', 'LC80120312021144LGN00', 'LC80110312021153LGN00', 'LC80120312021160LGN00', 'LC80110312021169LGN00', 'LC80120312021176LGN00', 'LC80110312021185LGN00', 'LC80120312021192LGN00', 'LC80110312021201LGN00', 'LC80120312021208LGN00', 'LC80110312021217LGN00', 'LC80120312021224LGN00', 'LC80110312021233LGN00', 'LC80120312021240LGN00', 'LC80110312021249LGN00', 'LC80120312021256LGN00', 'LC80110312021265LGN00', 'LC80120312021272LGN00', 'LC80110312021281LGN00', 'LC80120312021288LGN00', 'LC80110312021297LGN00', 'LC80120312021304LGN00', 'LC80110312021313LGN00', 'LC80120312021320LGN00'], dtype='<U21')
- view:sun_azimuth(time)float64149.6 148.3 147.6 ... 163.0 163.2
array([149.62504189, 148.25559842, 147.63548793, 146.57347971, 143.5156779 , 141.3785086 , 139.56493581, 137.19286205, 135.44751027, 132.55053618, 131.97708445, 132.14953865, 133.15220465, 134.49774521, 136.81191024, 138.96213191, 142.01465512, 144.52070954, 147.75701385, 150.20818382, 153.17993815, 155.30213327, 157.7211814 , 161.03812106, 162.99004094, 163.40667883, 163.5793306 , 163.44024391, 162.94511803, 161.36690501, 159.19772235, 158.16719592, 156.83010572, 154.54756242, 153.62443281, 152.50715747, 151.67968683, 150.65334477, 148.78449286, 146.52894678, 143.50996522, 139.56342251, 137.78555184, 135.43753379, 133.78292193, 132.1206217 , 131.31970225, 131.04590716, 131.46214164, 132.76523329, 134.30392195, 136.81517307, 139.08974286, 142.25322252, 144.80190291, 148.05625824, 150.50521599, 153.44100177, 155.5137163 , 157.85661022, 159.40518633, 161.01317062, 161.95567489, 162.7816719 , 163.12254171, 163.19315136, 162.97989489, 162.41187236, 161.76567817, 160.72660508, 159.80150851, 158.51935695, 157.48585192, 156.15347671, 155.14996305, 153.01388983, 151.91440632, 151.10411449, 150.08532348, 149.27490598, ... 156.53973142, 155.52128458, 154.27740568, 153.36061527, 152.24983269, 151.42921754, 150.41369107, 149.62070944, 148.54277607, 147.6272441 , 146.28928449, 143.25190419, 139.44047448, 137.59470621, 135.25852958, 133.63372008, 132.01277017, 131.24792828, 131.03962484, 131.50551499, 132.8619589 , 134.43325074, 136.99099597, 139.28512259, 142.46433834, 145.01687978, 148.2792739 , 150.71947552, 153.64012889, 155.70079545, 158.02670757, 159.5562764 , 161.13521432, 162.06446789, 163.22911139, 163.00633314, 162.41768427, 161.75873489, 160.71111988, 159.78322854, 158.49949669, 157.46223274, 156.1422038 , 155.14353499, 153.92221944, 153.02111088, 151.93998275, 151.13694961, 150.12220944, 149.31798677, 148.22203033, 147.27294819, 145.85961526, 142.67976119, 141.07228742, 138.76842452, 136.91872608, 134.64949435, 133.12042392, 131.69513112, 131.13554806, 131.20333498, 131.87088572, 133.46674803, 135.19922909, 137.90230869, 140.26556044, 143.49539312, 146.0541674 , 149.27695783, 151.66152647, 154.49729369, 156.47341904, 158.67149371, 160.09765008, 161.54671604, 162.36724433, 163.02578208, 163.24867084])
- description(band)<U91'Collection 2 Level-2 Coastal/Ae...
array(['Collection 2 Level-2 Coastal/Aerosol Band (B1) Surface Reflectance', 'Collection 2 Level-2 Blue Band (B2) Surface Reflectance', 'Collection 2 Level-2 Green Band (B3) Surface Reflectance', 'Collection 2 Level-2 Red Band (B4) Surface Reflectance', 'Collection 2 Level-2 Near Infrared Band 0.8 (B5) Surface Reflectance', 'Collection 2 Level-2 Short-wave Infrared Band 1.6 (B6) Surface Reflectance', 'Collection 2 Level-2 Short-wave Infrared Band 2.2 (B7) Surface Reflectance', 'Landsat Collection 2 Level-2 Surface Temperature Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Surface Temperature Band (B10) Surface Temperature Product', 'Landsat Collection 2 Level-2 Downwelled Radiance Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Emissivity Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Emissivity Standard Deviation Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Thermal Radiance Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Upwelled Radiance Band Surface Temperature Product', 'Collection 2 Level-1 Pixel Quality Assessment Band', 'Landsat Collection 2 Level-2 Atmospheric Transmittance Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Cloud Distance Band Surface Temperature Product', 'Collection 2 Level-1 Radiometric Saturation Quality Assessment Band', 'Collection 2 Level-2 Aerosol Quality Analysis Band (ANG) Surface Reflectance'], dtype='<U91')
- landsat:wrs_path(time)<U3'011' '012' '012' ... '011' '012'
array(['011', '012', '012', '012', '012', '011', '012', '011', '012', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '011', '011', '012', '011', '011', '012', '011', '012', '011', '011', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', ... '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012'], dtype='<U3')
- platform()<U9'landsat-8'
array('landsat-8', dtype='<U9')
- eo:cloud_cover(time)float6492.94 0.77 11.81 ... 0.07 1.59
array([9.294e+01, 7.700e-01, 1.181e+01, 1.176e+01, 8.000e-02, 9.830e+01, 6.145e+01, 3.610e+00, 3.849e+01, 1.485e+01, 9.701e+01, 4.060e+00, 6.344e+01, 8.257e+01, 3.419e+01, 3.300e-01, 1.700e-01, 7.695e+01, 3.617e+01, 9.500e-01, 3.669e+01, 1.500e-01, 1.180e+00, 1.490e+00, 1.000e+02, 5.575e+01, 7.640e+01, 1.000e+02, 9.996e+01, 9.412e+01, 1.000e+02, 2.059e+01, 1.000e+02, 2.650e+00, 7.982e+01, 7.669e+01, 9.993e+01, 9.902e+01, 3.000e-01, 7.100e-01, 7.563e+01, 5.917e+01, 1.160e+01, 1.895e+01, 3.335e+01, 2.505e+01, 2.029e+01, 8.351e+01, 8.238e+01, 8.675e+01, 8.787e+01, 1.000e+02, 1.640e+00, 1.060e+01, 4.000e-02, 4.884e+01, 7.218e+01, 2.226e+01, 2.037e+01, 3.300e+01, 6.100e-01, 9.848e+01, 4.360e+01, 1.000e+02, 1.197e+01, 3.529e+01, 2.480e+00, 9.579e+01, 1.663e+01, 1.000e+02, 3.445e+01, 1.000e+02, 3.486e+01, 5.810e+00, 9.600e+00, 1.000e+02, 1.000e+02, 1.000e+02, 1.000e+02, 9.997e+01, 1.000e+02, 8.473e+01, 1.334e+01, 9.197e+01, 3.286e+01, 5.800e-01, 9.996e+01, 9.996e+01, 9.759e+01, 7.780e+00, 1.000e+02, 4.380e+00, 3.274e+01, 8.686e+01, 6.320e+01, 2.147e+01, 8.024e+01, 6.680e+00, 2.000e-02, 1.620e+01, 9.358e+01, 5.647e+01, 2.360e+00, 1.340e+00, 9.999e+01, 1.780e+00, 1.000e-02, 8.670e+00, 4.440e+00, 9.993e+01, 4.430e+01, 9.996e+01, 9.679e+01, 6.290e+00, 5.351e+01, 3.516e+01, 5.820e+00, 1.000e+02, 7.176e+01, 3.691e+01, ... 7.706e+01, 3.270e+00, 6.860e+01, 3.000e-02, 1.000e+02, 8.406e+01, 9.999e+01, 9.481e+01, 9.624e+01, 1.829e+01, 9.999e+01, 1.000e+02, 9.796e+01, 4.523e+01, 5.436e+01, 7.694e+01, 1.207e+01, 8.059e+01, 5.325e+01, 9.530e+01, 3.371e+01, 2.893e+01, 1.698e+01, 1.924e+01, 6.010e+01, 9.887e+01, 1.900e+01, 1.113e+01, 3.400e-01, 4.317e+01, 9.993e+01, 1.000e+02, 5.526e+01, 9.535e+01, 7.173e+01, 2.764e+01, 7.966e+01, 9.807e+01, 5.900e-01, 6.020e+00, 8.430e+00, 2.700e+00, 6.000e-02, 4.819e+01, 2.080e+00, 1.220e+00, 4.293e+01, 1.000e+02, 2.141e+01, 9.932e+01, 3.100e-01, 3.300e-01, 7.558e+01, 7.017e+01, 5.567e+01, 6.878e+01, 7.090e+01, 5.123e+01, 9.915e+01, 8.513e+01, 2.198e+01, 1.577e+01, 9.420e+00, 4.708e+01, 8.784e+01, 1.000e+02, 6.930e+00, 3.368e+01, 9.557e+01, 5.380e+01, 8.696e+01, 1.000e+02, 9.425e+01, 1.700e-01, 9.934e+01, 2.300e+00, 1.757e+01, 1.000e+02, 9.992e+01, 7.411e+01, 3.355e+01, 9.999e+01, 4.861e+01, 3.329e+01, 6.360e+00, 2.553e+01, 6.030e+00, 1.800e-01, 2.000e-02, 3.993e+01, 5.824e+01, 3.460e+00, 9.998e+01, 1.270e+00, 5.195e+01, 5.501e+01, 5.017e+01, 2.290e+00, 9.329e+01, 9.434e+01, 8.980e+01, 1.158e+01, 5.000e-02, 9.996e+01, 2.139e+01, 3.192e+01, 7.544e+01, 8.091e+01, 1.080e+01, 2.499e+01, 1.069e+01, 3.090e+00, 4.478e+01, 2.100e-01, 3.255e+01, 7.000e-02, 1.590e+00])
- landsat:wrs_type()<U1'2'
array('2', dtype='<U1')
- landsat:cloud_cover_land(time)float6490.98 1.51 15.5 ... 36.35 0.54 2.08
array([9.098e+01, 1.510e+00, 1.550e+01, 1.483e+01, 9.000e-02, 9.785e+01, 6.750e+01, 1.350e+00, 4.337e+01, 7.410e+00, 8.166e+01, 5.490e+00, 2.527e+01, 8.131e+01, 1.500e-01, 5.800e-01, 8.200e-01, 7.823e+01, 3.148e+01, 1.460e+00, 4.881e+01, 2.500e-01, 1.570e+00, 7.500e-01, 1.000e+02, 5.482e+01, 7.518e+01, 1.000e+02, 1.000e+02, 9.790e+01, 1.000e+02, 3.339e+01, 1.000e+02, 8.780e+00, 8.246e+01, 7.588e+01, 9.987e+01, 9.804e+01, 3.270e+00, 2.500e-01, 5.056e+01, 5.551e+01, 1.009e+01, 5.100e-01, 4.320e+01, 2.203e+01, 2.587e+01, 9.673e+01, 9.012e+01, 7.491e+01, 8.613e+01, 1.000e+02, 2.820e+00, 2.400e+01, 6.000e-02, 5.112e+01, 7.882e+01, 1.255e+01, 6.100e+00, 4.000e-02, 1.600e-01, 9.939e+01, 3.680e+01, 1.000e+02, 2.044e+01, 2.975e+01, 3.830e+00, 9.999e+01, 4.810e+00, 1.000e+02, 2.449e+01, 1.000e+02, 2.255e+01, 1.230e+01, 8.810e+00, 9.999e+01, 1.000e+02, 1.000e+02, 1.000e+02, 1.000e+02, 1.000e+02, 8.824e+01, 1.030e+00, 9.920e+01, 9.750e+00, 1.600e-01, 1.000e+02, 9.999e+01, 8.625e+01, 1.325e+01, 1.000e+02, 7.600e-01, 1.970e+00, 8.008e+01, 2.190e+01, 2.370e+01, 9.902e+01, 1.171e+01, 1.600e-01, 2.200e+00, 8.713e+01, 6.033e+01, 1.228e+01, 2.900e-01, 1.000e+02, 9.500e-01, 1.300e-01, 1.430e+00, 2.290e+00, 1.000e+02, 1.777e+01, 9.993e+01, 9.999e+01, 1.099e+01, 4.295e+01, 4.811e+01, 1.790e+00, 1.000e+02, 5.425e+01, 2.283e+01, ... 8.770e+01, 5.500e+00, 7.790e+01, 4.000e-02, 1.000e+02, 7.805e+01, 1.000e+02, 9.728e+01, 9.915e+01, 2.690e+01, 1.000e+02, 1.000e+02, 9.149e+01, 4.081e+01, 1.789e+01, 8.684e+01, 4.500e-01, 8.793e+01, 1.678e+01, 9.496e+01, 1.838e+01, 3.599e+01, 1.309e+01, 3.254e+01, 6.500e+01, 9.804e+01, 2.230e+00, 1.395e+01, 5.300e-01, 5.418e+01, 1.000e+02, 1.000e+02, 8.843e+01, 9.999e+01, 9.934e+01, 3.538e+01, 8.829e+01, 9.666e+01, 5.570e+00, 4.920e+00, 4.500e-01, 4.520e+00, 4.600e-01, 7.137e+01, 1.050e+00, 2.130e+00, 2.580e+01, 1.000e+02, 5.164e+01, 9.723e+01, 5.000e-01, 1.000e-01, 3.439e+01, 5.539e+01, 6.356e+01, 5.995e+01, 8.879e+01, 7.155e+01, 9.997e+01, 8.073e+01, 5.321e+01, 2.524e+01, 8.480e+00, 5.610e+01, 9.960e+01, 9.999e+01, 1.611e+01, 2.704e+01, 9.998e+01, 4.007e+01, 9.715e+01, 1.000e+02, 1.000e+02, 2.900e-01, 9.918e+01, 3.780e+00, 1.641e+01, 1.000e+02, 1.000e+02, 7.747e+01, 4.900e-01, 9.999e+01, 2.588e+01, 4.281e+01, 1.500e-01, 3.754e+01, 5.420e+00, 2.900e-01, 1.800e-01, 3.107e+01, 1.000e+02, 2.500e-01, 1.000e+02, 3.820e+00, 3.799e+01, 1.289e+01, 3.450e+01, 2.500e-01, 9.763e+01, 1.000e+02, 8.986e+01, 1.000e-01, 7.000e-02, 9.998e+01, 1.897e+01, 2.107e+01, 7.670e+01, 7.338e+01, 8.700e+00, 6.867e+01, 5.780e+00, 6.400e-01, 2.469e+01, 2.000e-02, 3.635e+01, 5.400e-01, 2.080e+00])
- landsat:wrs_row()<U3'031'
array('031', dtype='<U3')
- landsat:collection_number()<U2'02'
array('02', dtype='<U2')
- landsat:processing_level()<U4'L2SP'
array('L2SP', dtype='<U4')
- view:off_nadir()int640
array(0)
- gsd(band)float6430.0 30.0 30.0 ... 30.0 30.0 30.0
array([ 30., 30., 30., 30., 30., 30., 30., 30., 100., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.])
- title(band)<U46'Coastal/Aerosol Band (B1)' ... ...
array(['Coastal/Aerosol Band (B1)', 'Blue Band (B2)', 'Green Band (B3)', 'Red Band (B4)', 'Near Infrared Band 0.8 (B5)', 'Short-wave Infrared Band 1.6 (B6)', 'Short-wave Infrared Band 2.2 (B7)', 'Surface Temperature Quality Assessment Band', 'Surface Temperature Band (B10)', 'Downwelled Radiance Band', 'Emissivity Band', 'Emissivity Standard Deviation Band', 'Thermal Radiance Band', 'Upwelled Radiance Band', 'Pixel Quality Assessment Band', 'Atmospheric Transmittance Band', 'Cloud Distance Band', 'Radiometric Saturation Quality Assessment Band', 'Aerosol Quality Analysis Band'], dtype='<U46')
- common_name(band)object'coastal' 'blue' ... None None
array(['coastal', 'blue', 'green', 'red', 'nir08', 'swir16', 'swir22', None, 'lwir11', None, None, None, None, None, None, None, None, None, None], dtype=object)
- center_wavelength(band)object0.44 0.48 0.56 ... None None None
array([0.44, 0.48, 0.56, 0.65, 0.86, 1.6, 2.2, None, 10.9, None, None, None, None, None, None, None, None, None, None], dtype=object)
- full_width_half_max(band)object0.02 0.06 0.06 ... None None None
array([0.02, 0.06, 0.06, 0.04, 0.03, 0.08, 0.2, None, 0.8, None, None, None, None, None, None, None, None, None, None], dtype=object)
- epsg()int6432619
array(32619)
- spec :
- RasterSpec(epsg=32619, bounds=(403980.0, 4599690.0, 438720.0, 4622880.0), resolutions_xy=(30.0, 30.0))
- crs :
- epsg:32619
- transform :
- | 30.00, 0.00, 403980.00| | 0.00,-30.00, 4622880.00| | 0.00, 0.00, 1.00|
- resolution :
- 30.0
And that’s it for stackstac! Everything from here on is just standard xarray operations.
[9]:
# use common_name for bands
stack = stack.assign_coords(band=stack.common_name.fillna(stack.band).rename("band"))
stack.band
[9]:
<xarray.DataArray 'band' (band: 19)> array(['coastal', 'blue', 'green', 'red', 'nir08', 'swir16', 'swir22', 'ST_QA', 'lwir11', 'ST_DRAD', 'ST_EMIS', 'ST_EMSD', 'ST_TRAD', 'ST_URAD', 'QA_PIXEL', 'ST_ATRAN', 'ST_CDIST', 'QA_RADSAT', 'SR_QA_AEROSOL'], dtype=object) Coordinates: * band (band) object 'coastal' ... 'SR_QA_AEROSOL' proj:epsg int64 32619 instruments object {'tirs', 'oli'} description (band) <U91 'Collection 2 Level-2 Coastal/Aero... platform <U9 'landsat-8' landsat:wrs_type <U1 '2' landsat:wrs_row <U3 '031' landsat:collection_number <U2 '02' landsat:processing_level <U4 'L2SP' view:off_nadir int64 0 gsd (band) float64 30.0 30.0 30.0 ... 30.0 30.0 30.0 title (band) <U46 'Coastal/Aerosol Band (B1)' ... 'A... common_name (band) object 'coastal' 'blue' ... None None center_wavelength (band) object 0.44 0.48 0.56 ... None None None full_width_half_max (band) object 0.02 0.06 0.06 ... None None None epsg int64 32619
- band: 19
- 'coastal' 'blue' 'green' ... 'ST_CDIST' 'QA_RADSAT' 'SR_QA_AEROSOL'
array(['coastal', 'blue', 'green', 'red', 'nir08', 'swir16', 'swir22', 'ST_QA', 'lwir11', 'ST_DRAD', 'ST_EMIS', 'ST_EMSD', 'ST_TRAD', 'ST_URAD', 'QA_PIXEL', 'ST_ATRAN', 'ST_CDIST', 'QA_RADSAT', 'SR_QA_AEROSOL'], dtype=object)
- band(band)object'coastal' ... 'SR_QA_AEROSOL'
array(['coastal', 'blue', 'green', 'red', 'nir08', 'swir16', 'swir22', 'ST_QA', 'lwir11', 'ST_DRAD', 'ST_EMIS', 'ST_EMSD', 'ST_TRAD', 'ST_URAD', 'QA_PIXEL', 'ST_ATRAN', 'ST_CDIST', 'QA_RADSAT', 'SR_QA_AEROSOL'], dtype=object)
- proj:epsg()int6432619
array(32619)
- instruments()object{'tirs', 'oli'}
array({'tirs', 'oli'}, dtype=object)
- description(band)<U91'Collection 2 Level-2 Coastal/Ae...
array(['Collection 2 Level-2 Coastal/Aerosol Band (B1) Surface Reflectance', 'Collection 2 Level-2 Blue Band (B2) Surface Reflectance', 'Collection 2 Level-2 Green Band (B3) Surface Reflectance', 'Collection 2 Level-2 Red Band (B4) Surface Reflectance', 'Collection 2 Level-2 Near Infrared Band 0.8 (B5) Surface Reflectance', 'Collection 2 Level-2 Short-wave Infrared Band 1.6 (B6) Surface Reflectance', 'Collection 2 Level-2 Short-wave Infrared Band 2.2 (B7) Surface Reflectance', 'Landsat Collection 2 Level-2 Surface Temperature Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Surface Temperature Band (B10) Surface Temperature Product', 'Landsat Collection 2 Level-2 Downwelled Radiance Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Emissivity Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Emissivity Standard Deviation Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Thermal Radiance Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Upwelled Radiance Band Surface Temperature Product', 'Collection 2 Level-1 Pixel Quality Assessment Band', 'Landsat Collection 2 Level-2 Atmospheric Transmittance Band Surface Temperature Product', 'Landsat Collection 2 Level-2 Cloud Distance Band Surface Temperature Product', 'Collection 2 Level-1 Radiometric Saturation Quality Assessment Band', 'Collection 2 Level-2 Aerosol Quality Analysis Band (ANG) Surface Reflectance'], dtype='<U91')
- platform()<U9'landsat-8'
array('landsat-8', dtype='<U9')
- landsat:wrs_type()<U1'2'
array('2', dtype='<U1')
- landsat:wrs_row()<U3'031'
array('031', dtype='<U3')
- landsat:collection_number()<U2'02'
array('02', dtype='<U2')
- landsat:processing_level()<U4'L2SP'
array('L2SP', dtype='<U4')
- view:off_nadir()int640
array(0)
- gsd(band)float6430.0 30.0 30.0 ... 30.0 30.0 30.0
array([ 30., 30., 30., 30., 30., 30., 30., 30., 100., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.])
- title(band)<U46'Coastal/Aerosol Band (B1)' ... ...
array(['Coastal/Aerosol Band (B1)', 'Blue Band (B2)', 'Green Band (B3)', 'Red Band (B4)', 'Near Infrared Band 0.8 (B5)', 'Short-wave Infrared Band 1.6 (B6)', 'Short-wave Infrared Band 2.2 (B7)', 'Surface Temperature Quality Assessment Band', 'Surface Temperature Band (B10)', 'Downwelled Radiance Band', 'Emissivity Band', 'Emissivity Standard Deviation Band', 'Thermal Radiance Band', 'Upwelled Radiance Band', 'Pixel Quality Assessment Band', 'Atmospheric Transmittance Band', 'Cloud Distance Band', 'Radiometric Saturation Quality Assessment Band', 'Aerosol Quality Analysis Band'], dtype='<U46')
- common_name(band)object'coastal' 'blue' ... None None
array(['coastal', 'blue', 'green', 'red', 'nir08', 'swir16', 'swir22', None, 'lwir11', None, None, None, None, None, None, None, None, None, None], dtype=object)
- center_wavelength(band)object0.44 0.48 0.56 ... None None None
array([0.44, 0.48, 0.56, 0.65, 0.86, 1.6, 2.2, None, 10.9, None, None, None, None, None, None, None, None, None, None], dtype=object)
- full_width_half_max(band)object0.02 0.06 0.06 ... None None None
array([0.02, 0.06, 0.06, 0.04, 0.03, 0.08, 0.2, None, 0.8, None, None, None, None, None, None, None, None, None, None], dtype=object)
- epsg()int6432619
array(32619)
See how much input data there is for just RGB. This is the amount of data we’ll end up processing
[10]:
stack.sel(band=["red", "green", "blue"])
[10]:
<xarray.DataArray 'stackstac-bae570f2cbe4987fda83bcd5371b5a40' (time: 375, band: 3, y: 773, x: 1158)> dask.array<getitem, shape=(375, 3, 773, 1158), dtype=float64, chunksize=(1, 1, 773, 1024), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2013-03-22T15:19:00.54... id (time) <U31 'LC08_L2SP_011031_20130322_02_T1... * band (band) object 'red' 'green' 'blue' * x (x) float64 4.04e+05 4.04e+05 ... 4.387e+05 * y (y) float64 4.623e+06 4.623e+06 ... 4.6e+06 proj:epsg int64 32619 instruments object {'tirs', 'oli'} view:sun_elevation (time) float64 44.94 50.04 51.92 ... 29.5 27.64 landsat:collection_category (time) <U2 'T1' 'T1' 'T1' ... 'T1' 'T1' 'T1' landsat:scene_id (time) <U21 'LC80110312013081LGN02' ... 'LC8... view:sun_azimuth (time) float64 149.6 148.3 ... 163.0 163.2 description (band) <U91 'Collection 2 Level-2 Red Band (... landsat:wrs_path (time) <U3 '011' '012' '012' ... '011' '012' platform <U9 'landsat-8' eo:cloud_cover (time) float64 92.94 0.77 11.81 ... 0.07 1.59 landsat:wrs_type <U1 '2' landsat:cloud_cover_land (time) float64 90.98 1.51 15.5 ... 0.54 2.08 landsat:wrs_row <U3 '031' landsat:collection_number <U2 '02' landsat:processing_level <U4 'L2SP' view:off_nadir int64 0 gsd (band) float64 30.0 30.0 30.0 title (band) <U46 'Red Band (B4)' ... 'Blue Band (... common_name (band) object 'red' 'green' 'blue' center_wavelength (band) object 0.65 0.56 0.48 full_width_half_max (band) object 0.04 0.06 0.06 epsg int64 32619 Attributes: spec: RasterSpec(epsg=32619, bounds=(403980.0, 4599690.0, 438720.0... crs: epsg:32619 transform: | 30.00, 0.00, 403980.00|\n| 0.00,-30.00, 4622880.00|\n| 0.0... resolution: 30.0
- time: 375
- band: 3
- y: 773
- x: 1158
- dask.array<chunksize=(1, 1, 773, 1024), meta=np.ndarray>
Array Chunk Bytes 7.50 GiB 6.04 MiB Shape (375, 3, 773, 1158) (1, 1, 773, 1024) Count 30752 Tasks 2250 Chunks Type float64 numpy.ndarray 375 1 1158 773 3 - time(time)datetime64[ns]2013-03-22T15:19:00.545659 ... 2...
array(['2013-03-22T15:19:00.545659000', '2013-04-04T15:27:44.408822000', '2013-04-09T15:27:54.193621000', ..., '2021-10-31T15:27:32.442147000', '2021-11-09T15:21:19.257057000', '2021-11-16T15:27:27.116402000'], dtype='datetime64[ns]')
- id(time)<U31'LC08_L2SP_011031_20130322_02_T1...
array(['LC08_L2SP_011031_20130322_02_T1', 'LC08_L2SP_012031_20130404_02_T1', 'LC08_L2SP_012031_20130409_02_T1', 'LC08_L2SP_012031_20130416_02_T1', 'LC08_L2SP_012031_20130502_02_T1', 'LC08_L2SP_011031_20130511_02_T1', 'LC08_L2SP_012031_20130518_02_T1', 'LC08_L2SP_011031_20130527_02_T1', 'LC08_L2SP_012031_20130603_02_T2', 'LC08_L2SP_012031_20130619_02_T1', 'LC08_L2SP_011031_20130628_02_T2', 'LC08_L2SP_012031_20130705_02_T1', 'LC08_L2SP_011031_20130714_02_T1', 'LC08_L2SP_012031_20130721_02_T1', 'LC08_L2SP_011031_20130730_02_T1', 'LC08_L2SP_012031_20130806_02_T1', 'LC08_L2SP_011031_20130815_02_T1', 'LC08_L2SP_012031_20130822_02_T1', 'LC08_L2SP_011031_20130831_02_T1', 'LC08_L2SP_012031_20130907_02_T1', ... 'LC08_L2SP_011031_20210618_02_T1', 'LC08_L2SP_012031_20210625_02_T2', 'LC08_L2SP_011031_20210704_02_T2', 'LC08_L2SP_012031_20210711_02_T1', 'LC08_L2SP_011031_20210720_02_T1', 'LC08_L2SP_012031_20210727_02_T1', 'LC08_L2SP_011031_20210805_02_T2', 'LC08_L2SP_012031_20210812_02_T1', 'LC08_L2SP_011031_20210821_02_T1', 'LC08_L2SP_012031_20210828_02_T1', 'LC08_L2SP_011031_20210906_02_T1', 'LC08_L2SP_012031_20210913_02_T1', 'LC08_L2SP_011031_20210922_02_T1', 'LC08_L2SP_012031_20210929_02_T1', 'LC08_L2SP_011031_20211008_02_T1', 'LC08_L2SP_012031_20211015_02_T1', 'LC08_L2SP_011031_20211024_02_T1', 'LC08_L2SP_012031_20211031_02_T1', 'LC08_L2SP_011031_20211109_02_T1', 'LC08_L2SP_012031_20211116_02_T1'], dtype='<U31')
- band(band)object'red' 'green' 'blue'
array(['red', 'green', 'blue'], dtype=object)
- x(x)float644.04e+05 4.04e+05 ... 4.387e+05
array([403980., 404010., 404040., ..., 438630., 438660., 438690.])
- y(y)float644.623e+06 4.623e+06 ... 4.6e+06
array([4622880., 4622850., 4622820., ..., 4599780., 4599750., 4599720.])
- proj:epsg()int6432619
array(32619)
- instruments()object{'tirs', 'oli'}
array({'tirs', 'oli'}, dtype=object)
- view:sun_elevation(time)float6444.94 50.04 51.92 ... 29.5 27.64
array([44.94417071, 50.03688029, 51.91632915, 54.41131525, 59.40718374, 61.6556255 , 63.07418224, 64.43888487, 65.13444578, 65.55535015, 65.14954169, 64.55106938, 63.45818749, 62.38129249, 60.7259742 , 59.2360822 , 57.08116314, 55.22892055, 52.63960694, 50.47736556, 47.54839298, 45.17739203, 42.05985671, 36.51448601, 31.33641965, 29.30304958, 26.99128606, 25.4692469 , 23.93148476, 22.52691318, 22.98414564, 23.77791608, 25.29993771, 29.2553281 , 31.41001757, 34.47053286, 37.02887416, 40.46582911, 46.72449765, 52.72170122, 57.94968345, 61.94545945, 63.2550021 , 64.44792066, 65.01188877, 65.2859204 , 65.16968217, 64.63613449, 63.95535596, 62.7746641 , 61.63358442, 59.9030512 , 58.36487079, 56.15327755, 54.2573929 , 51.62087626, 49.43339573, 46.47909572, 44.095653 , 40.98096133, 38.55270431, 35.48977112, 33.19446095, 30.43494534, 28.47986937, 26.28658186, 24.87144921, 23.4905364 , 22.7873144 , 22.39498089, 22.50321376, 23.17627819, 24.10642545, 25.79187975, 27.4578998 , 32.23510075, 35.38106331, 37.98843546, 41.46217367, 44.20978811, 47.71627192, 50.37402799, 53.62036853, 58.66969931, 62.44795416, 63.61521835, 64.64864251, 65.09087471, 65.21437718, 64.99282172, 64.34433852, 63.58119259, 62.30094448, 61.09216398, 59.28361053, 57.68336158, 55.39548415, 53.44933689, 50.7554881 , 48.52670782, ... 58.88406639, 56.73774443, 54.8900685 , 52.30738256, 50.15303823, 47.23598858, 44.87313193, 41.76571725, 39.33293321, 36.24925576, 33.92395458, 31.10309232, 29.08917462, 26.80222699, 25.30102211, 23.79368444, 22.9844411 , 22.44959394, 22.44221807, 22.96943006, 23.7894223 , 25.34485821, 26.91687549, 29.35179125, 31.52492038, 34.6049865 , 37.17571768, 40.62377703, 43.36717767, 46.88765574, 49.57374914, 52.87421508, 58.0733433 , 62.06345985, 63.33101929, 64.4930502 , 65.03481102, 65.27959198, 65.14129066, 64.58738906, 63.8921047 , 62.69209778, 61.53639053, 59.79414255, 58.2446115 , 56.01759531, 54.11064638, 51.46570481, 49.26927073, 46.3051155 , 43.91847047, 40.80345206, 38.37588833, 35.31625681, 33.0308533 , 26.17516599, 24.78409761, 23.43425605, 22.75692163, 22.40174678, 22.54022423, 23.25047467, 24.20774447, 25.9291269 , 27.61839864, 30.18330532, 32.44065724, 35.60646289, 38.22322897, 41.70587965, 44.456239 , 47.96101262, 50.61426932, 53.84868612, 58.86639313, 60.69436524, 62.61497657, 63.76009737, 64.76139035, 65.17846013, 65.27223078, 65.0310067 , 64.35614877, 63.57254714, 62.27136981, 61.04664145, 59.21514756, 57.59715835, 55.29254678, 53.33189574, 50.61963618, 48.37857161, 45.3771016 , 42.97228493, 39.84688448, 37.42808639, 34.40746637, 32.16598462, 29.49837575, 27.63990895])
- landsat:collection_category(time)<U2'T1' 'T1' 'T1' ... 'T1' 'T1' 'T1'
array(['T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T2', 'T1', 'T2', 'T2', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T2', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T2', 'T2', 'T2', 'T2', 'T2', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T2', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T2', 'T2', 'T1', 'T1', 'T1', 'T2', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1', 'T1'], dtype='<U2')
- landsat:scene_id(time)<U21'LC80110312013081LGN02' ... 'LC8...
array(['LC80110312013081LGN02', 'LC80120312013094LGN02', 'LC80120312013099LGN02', 'LC80120312013106LGN03', 'LC80120312013122LGN02', 'LC80110312013131LGN02', 'LC80120312013138LGN02', 'LC80110312013147LGN01', 'LC80120312013154LGN01', 'LC80120312013170LGN01', 'LC80110312013179LGN01', 'LC80120312013186LGN01', 'LC80110312013195LGN01', 'LC80120312013202LGN01', 'LC80110312013211LGN01', 'LC80120312013218LGN01', 'LC80110312013227LGN01', 'LC80120312013234LGN01', 'LC80110312013243LGN01', 'LC80120312013250LGN01', 'LC80110312013259LGN01', 'LC80120312013266LGN01', 'LC80110312013275LGN01', 'LC80110312013291LGN01', 'LC80110312013307LGN01', 'LC80120312013314LGN01', 'LC80110312013323LGN01', 'LC80120312013330LGN01', 'LC80110312013339LGN04', 'LC80110312013355LGN02', 'LC80110312014006LGN01', 'LC80120312014013LGN01', 'LC80110312014022LGN01', 'LC80110312014038LGN01', 'LC80120312014045LGN01', 'LC80110312014054LGN01', 'LC80120312014061LGN03', 'LC80110312014070LGN01', 'LC80110312014086LGN01', 'LC80110312014102LGN01', ... 'LC80110312021009LGN00', 'LC80120312021016LGN00', 'LC80110312021025LGN00', 'LC80120312021032LGN00', 'LC80110312021041LGN00', 'LC80120312021048LGN00', 'LC80110312021057LGN00', 'LC80120312021064LGN00', 'LC80110312021073LGN00', 'LC80120312021080LGN00', 'LC80110312021089LGN00', 'LC80120312021096LGN00', 'LC80110312021105LGN00', 'LC80110312021121LGN00', 'LC80120312021128LGN00', 'LC80110312021137LGN00', 'LC80120312021144LGN00', 'LC80110312021153LGN00', 'LC80120312021160LGN00', 'LC80110312021169LGN00', 'LC80120312021176LGN00', 'LC80110312021185LGN00', 'LC80120312021192LGN00', 'LC80110312021201LGN00', 'LC80120312021208LGN00', 'LC80110312021217LGN00', 'LC80120312021224LGN00', 'LC80110312021233LGN00', 'LC80120312021240LGN00', 'LC80110312021249LGN00', 'LC80120312021256LGN00', 'LC80110312021265LGN00', 'LC80120312021272LGN00', 'LC80110312021281LGN00', 'LC80120312021288LGN00', 'LC80110312021297LGN00', 'LC80120312021304LGN00', 'LC80110312021313LGN00', 'LC80120312021320LGN00'], dtype='<U21')
- view:sun_azimuth(time)float64149.6 148.3 147.6 ... 163.0 163.2
array([149.62504189, 148.25559842, 147.63548793, 146.57347971, 143.5156779 , 141.3785086 , 139.56493581, 137.19286205, 135.44751027, 132.55053618, 131.97708445, 132.14953865, 133.15220465, 134.49774521, 136.81191024, 138.96213191, 142.01465512, 144.52070954, 147.75701385, 150.20818382, 153.17993815, 155.30213327, 157.7211814 , 161.03812106, 162.99004094, 163.40667883, 163.5793306 , 163.44024391, 162.94511803, 161.36690501, 159.19772235, 158.16719592, 156.83010572, 154.54756242, 153.62443281, 152.50715747, 151.67968683, 150.65334477, 148.78449286, 146.52894678, 143.50996522, 139.56342251, 137.78555184, 135.43753379, 133.78292193, 132.1206217 , 131.31970225, 131.04590716, 131.46214164, 132.76523329, 134.30392195, 136.81517307, 139.08974286, 142.25322252, 144.80190291, 148.05625824, 150.50521599, 153.44100177, 155.5137163 , 157.85661022, 159.40518633, 161.01317062, 161.95567489, 162.7816719 , 163.12254171, 163.19315136, 162.97989489, 162.41187236, 161.76567817, 160.72660508, 159.80150851, 158.51935695, 157.48585192, 156.15347671, 155.14996305, 153.01388983, 151.91440632, 151.10411449, 150.08532348, 149.27490598, ... 156.53973142, 155.52128458, 154.27740568, 153.36061527, 152.24983269, 151.42921754, 150.41369107, 149.62070944, 148.54277607, 147.6272441 , 146.28928449, 143.25190419, 139.44047448, 137.59470621, 135.25852958, 133.63372008, 132.01277017, 131.24792828, 131.03962484, 131.50551499, 132.8619589 , 134.43325074, 136.99099597, 139.28512259, 142.46433834, 145.01687978, 148.2792739 , 150.71947552, 153.64012889, 155.70079545, 158.02670757, 159.5562764 , 161.13521432, 162.06446789, 163.22911139, 163.00633314, 162.41768427, 161.75873489, 160.71111988, 159.78322854, 158.49949669, 157.46223274, 156.1422038 , 155.14353499, 153.92221944, 153.02111088, 151.93998275, 151.13694961, 150.12220944, 149.31798677, 148.22203033, 147.27294819, 145.85961526, 142.67976119, 141.07228742, 138.76842452, 136.91872608, 134.64949435, 133.12042392, 131.69513112, 131.13554806, 131.20333498, 131.87088572, 133.46674803, 135.19922909, 137.90230869, 140.26556044, 143.49539312, 146.0541674 , 149.27695783, 151.66152647, 154.49729369, 156.47341904, 158.67149371, 160.09765008, 161.54671604, 162.36724433, 163.02578208, 163.24867084])
- description(band)<U91'Collection 2 Level-2 Red Band (...
array(['Collection 2 Level-2 Red Band (B4) Surface Reflectance', 'Collection 2 Level-2 Green Band (B3) Surface Reflectance', 'Collection 2 Level-2 Blue Band (B2) Surface Reflectance'], dtype='<U91')
- landsat:wrs_path(time)<U3'011' '012' '012' ... '011' '012'
array(['011', '012', '012', '012', '012', '011', '012', '011', '012', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '011', '011', '012', '011', '011', '012', '011', '012', '011', '011', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', ... '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012', '011', '012'], dtype='<U3')
- platform()<U9'landsat-8'
array('landsat-8', dtype='<U9')
- eo:cloud_cover(time)float6492.94 0.77 11.81 ... 0.07 1.59
array([9.294e+01, 7.700e-01, 1.181e+01, 1.176e+01, 8.000e-02, 9.830e+01, 6.145e+01, 3.610e+00, 3.849e+01, 1.485e+01, 9.701e+01, 4.060e+00, 6.344e+01, 8.257e+01, 3.419e+01, 3.300e-01, 1.700e-01, 7.695e+01, 3.617e+01, 9.500e-01, 3.669e+01, 1.500e-01, 1.180e+00, 1.490e+00, 1.000e+02, 5.575e+01, 7.640e+01, 1.000e+02, 9.996e+01, 9.412e+01, 1.000e+02, 2.059e+01, 1.000e+02, 2.650e+00, 7.982e+01, 7.669e+01, 9.993e+01, 9.902e+01, 3.000e-01, 7.100e-01, 7.563e+01, 5.917e+01, 1.160e+01, 1.895e+01, 3.335e+01, 2.505e+01, 2.029e+01, 8.351e+01, 8.238e+01, 8.675e+01, 8.787e+01, 1.000e+02, 1.640e+00, 1.060e+01, 4.000e-02, 4.884e+01, 7.218e+01, 2.226e+01, 2.037e+01, 3.300e+01, 6.100e-01, 9.848e+01, 4.360e+01, 1.000e+02, 1.197e+01, 3.529e+01, 2.480e+00, 9.579e+01, 1.663e+01, 1.000e+02, 3.445e+01, 1.000e+02, 3.486e+01, 5.810e+00, 9.600e+00, 1.000e+02, 1.000e+02, 1.000e+02, 1.000e+02, 9.997e+01, 1.000e+02, 8.473e+01, 1.334e+01, 9.197e+01, 3.286e+01, 5.800e-01, 9.996e+01, 9.996e+01, 9.759e+01, 7.780e+00, 1.000e+02, 4.380e+00, 3.274e+01, 8.686e+01, 6.320e+01, 2.147e+01, 8.024e+01, 6.680e+00, 2.000e-02, 1.620e+01, 9.358e+01, 5.647e+01, 2.360e+00, 1.340e+00, 9.999e+01, 1.780e+00, 1.000e-02, 8.670e+00, 4.440e+00, 9.993e+01, 4.430e+01, 9.996e+01, 9.679e+01, 6.290e+00, 5.351e+01, 3.516e+01, 5.820e+00, 1.000e+02, 7.176e+01, 3.691e+01, ... 7.706e+01, 3.270e+00, 6.860e+01, 3.000e-02, 1.000e+02, 8.406e+01, 9.999e+01, 9.481e+01, 9.624e+01, 1.829e+01, 9.999e+01, 1.000e+02, 9.796e+01, 4.523e+01, 5.436e+01, 7.694e+01, 1.207e+01, 8.059e+01, 5.325e+01, 9.530e+01, 3.371e+01, 2.893e+01, 1.698e+01, 1.924e+01, 6.010e+01, 9.887e+01, 1.900e+01, 1.113e+01, 3.400e-01, 4.317e+01, 9.993e+01, 1.000e+02, 5.526e+01, 9.535e+01, 7.173e+01, 2.764e+01, 7.966e+01, 9.807e+01, 5.900e-01, 6.020e+00, 8.430e+00, 2.700e+00, 6.000e-02, 4.819e+01, 2.080e+00, 1.220e+00, 4.293e+01, 1.000e+02, 2.141e+01, 9.932e+01, 3.100e-01, 3.300e-01, 7.558e+01, 7.017e+01, 5.567e+01, 6.878e+01, 7.090e+01, 5.123e+01, 9.915e+01, 8.513e+01, 2.198e+01, 1.577e+01, 9.420e+00, 4.708e+01, 8.784e+01, 1.000e+02, 6.930e+00, 3.368e+01, 9.557e+01, 5.380e+01, 8.696e+01, 1.000e+02, 9.425e+01, 1.700e-01, 9.934e+01, 2.300e+00, 1.757e+01, 1.000e+02, 9.992e+01, 7.411e+01, 3.355e+01, 9.999e+01, 4.861e+01, 3.329e+01, 6.360e+00, 2.553e+01, 6.030e+00, 1.800e-01, 2.000e-02, 3.993e+01, 5.824e+01, 3.460e+00, 9.998e+01, 1.270e+00, 5.195e+01, 5.501e+01, 5.017e+01, 2.290e+00, 9.329e+01, 9.434e+01, 8.980e+01, 1.158e+01, 5.000e-02, 9.996e+01, 2.139e+01, 3.192e+01, 7.544e+01, 8.091e+01, 1.080e+01, 2.499e+01, 1.069e+01, 3.090e+00, 4.478e+01, 2.100e-01, 3.255e+01, 7.000e-02, 1.590e+00])
- landsat:wrs_type()<U1'2'
array('2', dtype='<U1')
- landsat:cloud_cover_land(time)float6490.98 1.51 15.5 ... 36.35 0.54 2.08
array([9.098e+01, 1.510e+00, 1.550e+01, 1.483e+01, 9.000e-02, 9.785e+01, 6.750e+01, 1.350e+00, 4.337e+01, 7.410e+00, 8.166e+01, 5.490e+00, 2.527e+01, 8.131e+01, 1.500e-01, 5.800e-01, 8.200e-01, 7.823e+01, 3.148e+01, 1.460e+00, 4.881e+01, 2.500e-01, 1.570e+00, 7.500e-01, 1.000e+02, 5.482e+01, 7.518e+01, 1.000e+02, 1.000e+02, 9.790e+01, 1.000e+02, 3.339e+01, 1.000e+02, 8.780e+00, 8.246e+01, 7.588e+01, 9.987e+01, 9.804e+01, 3.270e+00, 2.500e-01, 5.056e+01, 5.551e+01, 1.009e+01, 5.100e-01, 4.320e+01, 2.203e+01, 2.587e+01, 9.673e+01, 9.012e+01, 7.491e+01, 8.613e+01, 1.000e+02, 2.820e+00, 2.400e+01, 6.000e-02, 5.112e+01, 7.882e+01, 1.255e+01, 6.100e+00, 4.000e-02, 1.600e-01, 9.939e+01, 3.680e+01, 1.000e+02, 2.044e+01, 2.975e+01, 3.830e+00, 9.999e+01, 4.810e+00, 1.000e+02, 2.449e+01, 1.000e+02, 2.255e+01, 1.230e+01, 8.810e+00, 9.999e+01, 1.000e+02, 1.000e+02, 1.000e+02, 1.000e+02, 1.000e+02, 8.824e+01, 1.030e+00, 9.920e+01, 9.750e+00, 1.600e-01, 1.000e+02, 9.999e+01, 8.625e+01, 1.325e+01, 1.000e+02, 7.600e-01, 1.970e+00, 8.008e+01, 2.190e+01, 2.370e+01, 9.902e+01, 1.171e+01, 1.600e-01, 2.200e+00, 8.713e+01, 6.033e+01, 1.228e+01, 2.900e-01, 1.000e+02, 9.500e-01, 1.300e-01, 1.430e+00, 2.290e+00, 1.000e+02, 1.777e+01, 9.993e+01, 9.999e+01, 1.099e+01, 4.295e+01, 4.811e+01, 1.790e+00, 1.000e+02, 5.425e+01, 2.283e+01, ... 8.770e+01, 5.500e+00, 7.790e+01, 4.000e-02, 1.000e+02, 7.805e+01, 1.000e+02, 9.728e+01, 9.915e+01, 2.690e+01, 1.000e+02, 1.000e+02, 9.149e+01, 4.081e+01, 1.789e+01, 8.684e+01, 4.500e-01, 8.793e+01, 1.678e+01, 9.496e+01, 1.838e+01, 3.599e+01, 1.309e+01, 3.254e+01, 6.500e+01, 9.804e+01, 2.230e+00, 1.395e+01, 5.300e-01, 5.418e+01, 1.000e+02, 1.000e+02, 8.843e+01, 9.999e+01, 9.934e+01, 3.538e+01, 8.829e+01, 9.666e+01, 5.570e+00, 4.920e+00, 4.500e-01, 4.520e+00, 4.600e-01, 7.137e+01, 1.050e+00, 2.130e+00, 2.580e+01, 1.000e+02, 5.164e+01, 9.723e+01, 5.000e-01, 1.000e-01, 3.439e+01, 5.539e+01, 6.356e+01, 5.995e+01, 8.879e+01, 7.155e+01, 9.997e+01, 8.073e+01, 5.321e+01, 2.524e+01, 8.480e+00, 5.610e+01, 9.960e+01, 9.999e+01, 1.611e+01, 2.704e+01, 9.998e+01, 4.007e+01, 9.715e+01, 1.000e+02, 1.000e+02, 2.900e-01, 9.918e+01, 3.780e+00, 1.641e+01, 1.000e+02, 1.000e+02, 7.747e+01, 4.900e-01, 9.999e+01, 2.588e+01, 4.281e+01, 1.500e-01, 3.754e+01, 5.420e+00, 2.900e-01, 1.800e-01, 3.107e+01, 1.000e+02, 2.500e-01, 1.000e+02, 3.820e+00, 3.799e+01, 1.289e+01, 3.450e+01, 2.500e-01, 9.763e+01, 1.000e+02, 8.986e+01, 1.000e-01, 7.000e-02, 9.998e+01, 1.897e+01, 2.107e+01, 7.670e+01, 7.338e+01, 8.700e+00, 6.867e+01, 5.780e+00, 6.400e-01, 2.469e+01, 2.000e-02, 3.635e+01, 5.400e-01, 2.080e+00])
- landsat:wrs_row()<U3'031'
array('031', dtype='<U3')
- landsat:collection_number()<U2'02'
array('02', dtype='<U2')
- landsat:processing_level()<U4'L2SP'
array('L2SP', dtype='<U4')
- view:off_nadir()int640
array(0)
- gsd(band)float6430.0 30.0 30.0
array([30., 30., 30.])
- title(band)<U46'Red Band (B4)' ... 'Blue Band (...
array(['Red Band (B4)', 'Green Band (B3)', 'Blue Band (B2)'], dtype='<U46')
- common_name(band)object'red' 'green' 'blue'
array(['red', 'green', 'blue'], dtype=object)
- center_wavelength(band)object0.65 0.56 0.48
array([0.65, 0.56, 0.48], dtype=object)
- full_width_half_max(band)object0.04 0.06 0.06
array([0.04, 0.06, 0.06], dtype=object)
- epsg()int6432619
array(32619)
- spec :
- RasterSpec(epsg=32619, bounds=(403980.0, 4599690.0, 438720.0, 4622880.0), resolutions_xy=(30.0, 30.0))
- crs :
- epsg:32619
- transform :
- | 30.00, 0.00, 403980.00| | 0.00,-30.00, 4622880.00| | 0.00, 0.00, 1.00|
- resolution :
- 30.0
Mask cloudy pixels using the QA band¶
Use the bit values of the Landsat-8 QA band to mask out bad pixels. We’ll mask pixels labeled as dilated cloud, cirrus, cloud, or cloud shadow. (By “mask”, we mean just replacing those pixels with NaNs).
See page 14 on this PDF for the data table describing which bit means what.
[11]:
# Make a bitmask---when we bitwise-and it with the data, it leaves just the 4 bits we care about
mask_bitfields = [1, 2, 3, 4] # dilated cloud, cirrus, cloud, cloud shadow
bitmask = 0
for field in mask_bitfields:
bitmask |= 1 << field
bin(bitmask)
[11]:
'0b11110'
[12]:
qa = stack.sel(band="QA_PIXEL").astype("uint16")
bad = qa & bitmask # just look at those 4 bits
good = stack.where(bad == 0) # mask pixels where any one of those bits are set
[13]:
# What's the typical interval between scenes?
good.time.diff("time").dt.days.plot.hist();
Make biannual median composites¶
The Landsat-8 scenes appear to typically be 5-15 days apart. Let’s composite that down to a 6-month interval.
Since the cloudy pixels we masked with NaNs will be ignored in the median
, this should give us a decent cloud-free-ish image for each.
[14]:
# Make biannual median composites (`2Q` means 2 quarters)
composites = good.resample(time="2Q").median("time")
composites
[14]:
<xarray.DataArray 'stackstac-bae570f2cbe4987fda83bcd5371b5a40' (time: 19, band: 19, y: 773, x: 1158)> dask.array<stack, shape=(19, 19, 773, 1158), dtype=float64, chunksize=(1, 1, 773, 512), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2013-03-31 ... 2022-03-31 * band (band) object 'coastal' ... 'SR_QA_AEROSOL' * x (x) float64 4.04e+05 4.04e+05 ... 4.387e+05 * y (y) float64 4.623e+06 4.623e+06 ... 4.6e+06 proj:epsg int64 32619 instruments object {'tirs', 'oli'} platform <U9 'landsat-8' landsat:wrs_type <U1 '2' landsat:wrs_row <U3 '031' landsat:collection_number <U2 '02' landsat:processing_level <U4 'L2SP' view:off_nadir int64 0 epsg int64 32619
- time: 19
- band: 19
- y: 773
- x: 1158
- dask.array<chunksize=(1, 1, 773, 512), meta=np.ndarray>
Array Chunk Bytes 2.41 GiB 3.02 MiB Shape (19, 19, 773, 1158) (1, 1, 773, 512) Count 78018 Tasks 1083 Chunks Type float64 numpy.ndarray 19 1 1158 773 19 - time(time)datetime64[ns]2013-03-31 ... 2022-03-31
array(['2013-03-31T00:00:00.000000000', '2013-09-30T00:00:00.000000000', '2014-03-31T00:00:00.000000000', '2014-09-30T00:00:00.000000000', '2015-03-31T00:00:00.000000000', '2015-09-30T00:00:00.000000000', '2016-03-31T00:00:00.000000000', '2016-09-30T00:00:00.000000000', '2017-03-31T00:00:00.000000000', '2017-09-30T00:00:00.000000000', '2018-03-31T00:00:00.000000000', '2018-09-30T00:00:00.000000000', '2019-03-31T00:00:00.000000000', '2019-09-30T00:00:00.000000000', '2020-03-31T00:00:00.000000000', '2020-09-30T00:00:00.000000000', '2021-03-31T00:00:00.000000000', '2021-09-30T00:00:00.000000000', '2022-03-31T00:00:00.000000000'], dtype='datetime64[ns]')
- band(band)object'coastal' ... 'SR_QA_AEROSOL'
array(['coastal', 'blue', 'green', 'red', 'nir08', 'swir16', 'swir22', 'ST_QA', 'lwir11', 'ST_DRAD', 'ST_EMIS', 'ST_EMSD', 'ST_TRAD', 'ST_URAD', 'QA_PIXEL', 'ST_ATRAN', 'ST_CDIST', 'QA_RADSAT', 'SR_QA_AEROSOL'], dtype=object)
- x(x)float644.04e+05 4.04e+05 ... 4.387e+05
array([403980., 404010., 404040., ..., 438630., 438660., 438690.])
- y(y)float644.623e+06 4.623e+06 ... 4.6e+06
array([4622880., 4622850., 4622820., ..., 4599780., 4599750., 4599720.])
- proj:epsg()int6432619
array(32619)
- instruments()object{'tirs', 'oli'}
array({'tirs', 'oli'}, dtype=object)
- platform()<U9'landsat-8'
array('landsat-8', dtype='<U9')
- landsat:wrs_type()<U1'2'
array('2', dtype='<U1')
- landsat:wrs_row()<U3'031'
array('031', dtype='<U3')
- landsat:collection_number()<U2'02'
array('02', dtype='<U2')
- landsat:processing_level()<U4'L2SP'
array('L2SP', dtype='<U4')
- view:off_nadir()int640
array(0)
- epsg()int6432619
array(32619)
Pick the red-green-blue bands to make a true-color image.
[15]:
rgb = composites.sel(band=["red", "green", "blue"])
rgb
[15]:
<xarray.DataArray 'stackstac-bae570f2cbe4987fda83bcd5371b5a40' (time: 19, band: 3, y: 773, x: 1158)> dask.array<getitem, shape=(19, 3, 773, 1158), dtype=float64, chunksize=(1, 1, 773, 512), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2013-03-31 ... 2022-03-31 * band (band) object 'red' 'green' 'blue' * x (x) float64 4.04e+05 4.04e+05 ... 4.387e+05 * y (y) float64 4.623e+06 4.623e+06 ... 4.6e+06 proj:epsg int64 32619 instruments object {'tirs', 'oli'} platform <U9 'landsat-8' landsat:wrs_type <U1 '2' landsat:wrs_row <U3 '031' landsat:collection_number <U2 '02' landsat:processing_level <U4 'L2SP' view:off_nadir int64 0 epsg int64 32619
- time: 19
- band: 3
- y: 773
- x: 1158
- dask.array<chunksize=(1, 1, 773, 512), meta=np.ndarray>
Array Chunk Bytes 389.27 MiB 3.02 MiB Shape (19, 3, 773, 1158) (1, 1, 773, 512) Count 78189 Tasks 171 Chunks Type float64 numpy.ndarray 19 1 1158 773 3 - time(time)datetime64[ns]2013-03-31 ... 2022-03-31
array(['2013-03-31T00:00:00.000000000', '2013-09-30T00:00:00.000000000', '2014-03-31T00:00:00.000000000', '2014-09-30T00:00:00.000000000', '2015-03-31T00:00:00.000000000', '2015-09-30T00:00:00.000000000', '2016-03-31T00:00:00.000000000', '2016-09-30T00:00:00.000000000', '2017-03-31T00:00:00.000000000', '2017-09-30T00:00:00.000000000', '2018-03-31T00:00:00.000000000', '2018-09-30T00:00:00.000000000', '2019-03-31T00:00:00.000000000', '2019-09-30T00:00:00.000000000', '2020-03-31T00:00:00.000000000', '2020-09-30T00:00:00.000000000', '2021-03-31T00:00:00.000000000', '2021-09-30T00:00:00.000000000', '2022-03-31T00:00:00.000000000'], dtype='datetime64[ns]')
- band(band)object'red' 'green' 'blue'
array(['red', 'green', 'blue'], dtype=object)
- x(x)float644.04e+05 4.04e+05 ... 4.387e+05
array([403980., 404010., 404040., ..., 438630., 438660., 438690.])
- y(y)float644.623e+06 4.623e+06 ... 4.6e+06
array([4622880., 4622850., 4622820., ..., 4599780., 4599750., 4599720.])
- proj:epsg()int6432619
array(32619)
- instruments()object{'tirs', 'oli'}
array({'tirs', 'oli'}, dtype=object)
- platform()<U9'landsat-8'
array('landsat-8', dtype='<U9')
- landsat:wrs_type()<U1'2'
array('2', dtype='<U1')
- landsat:wrs_row()<U3'031'
array('031', dtype='<U3')
- landsat:collection_number()<U2'02'
array('02', dtype='<U2')
- landsat:processing_level()<U4'L2SP'
array('L2SP', dtype='<U4')
- view:off_nadir()int640
array(0)
- epsg()int6432619
array(32619)
Some final cleanup to make a nicer-looking animation:
Forward-fill any NaN pixels from the previous frame, to make the animation look less jumpy.
Also skip the first frame, since its NaNs can’t be filled from anywhere.
[16]:
cleaned = rgb.ffill("time")[1:]
Render the GIF¶
Use GeoGIF to turn the stack into an animation. We’ll use dgif to render the GIF on the cluster, so there’s less data to send back. (GIFs are a lot smaller than NumPy arrays!)
[17]:
client.wait_for_workers(20)
[18]:
%%time
gif_img = geogif.dgif(cleaned).compute()
CPU times: user 3.44 s, sys: 309 ms, total: 3.75 s
Wall time: 49.9 s
[19]:
# we turned ~7GiB of data into a 4MB GIF!
dask.utils.format_bytes(len(gif_img.data))
[19]:
'4.38 MiB'
[21]:
gif_img
[21]: