-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path1-read-stac-python.html
2448 lines (1456 loc) · 84.9 KB
/
1-read-stac-python.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Read-a-STAC-Catalog-Using-PySTAC">Read a STAC Catalog Using PySTAC<a class="anchor-link" href="#Read-a-STAC-Catalog-Using-PySTAC">¶</a></h1>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>In this tutorial, you will gain an understanding of how to explore a STAC Catalog using <a href="https://pystac.readthedocs.io/en/stable/index.html">PySTAC</a>. You will be able to use these skills to explore any of the <a href="https://stacindex.org/catalogs">many existing STAC Catalogs</a>.</p>
<p>This tutorial as well as the following 3 tutorials were adapted from the <a href="https://pystac.readthedocs.io/en/stable/index.html">PySTAC site tutorials</a>.</p>
<p>Throughout this tutorial, a variety of PySTAC classes, methods, and instances are used to read the STAC Catalog. We encourage you to look at the <a href="https://pystac.readthedocs.io/en/latest/api.html">PySTAC API Reference</a> while going through this tutorial.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Dependencies">Dependencies<a class="anchor-link" href="#Dependencies">¶</a></h2><p>If you need to install pystac, uncomment the line below and run this cell.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [1]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># ! pip install pystac</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="STAC-Catalogs">STAC Catalogs<a class="anchor-link" href="#STAC-Catalogs">¶</a></h2><p><a href="https://github.com/radiantearth/stac-spec/tree/master/catalog-spec">A STAC Catalog</a> is used to group other STAC objects like items, collections, and/or even other catalogs.</p>
<p>We will be using a small example catalog adapted from the <a href="https://github.com/geotrellis/geotrellis-server/tree/977bad7a64c409341479c281c8c72222008861fd/stac-example/catalog/landsat-stac-collection">example Landsat Collection</a> in the <a href="https://geotrellis.io">GeoTrellis</a> repository. All STAC Items and Collections can be found in the <a href="https://github.com/stac-utils/pystac/tree/main/docs/example-catalog">docs/example-catalog</a> directory of the PySTAC documentation repository; all assets are hosted in the Landsat S3 bucket.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="Import-Packages-and-Store-Data">Import Packages and Store Data<a class="anchor-link" href="#Import-Packages-and-Store-Data">¶</a></h4><p>To begin, import the packages and PySTAC classes that you need to access data and work with STAC Catalogs in Python.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [2]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">json</span>
<span class="kn">from</span> <span class="nn">pystac</span> <span class="kn">import</span> <span class="n">Catalog</span><span class="p">,</span> <span class="n">get_stac_version</span>
<span class="kn">from</span> <span class="nn">pystac.extensions.eo</span> <span class="kn">import</span> <span class="n">EOExtension</span>
<span class="kn">from</span> <span class="nn">pystac.extensions.label</span> <span class="kn">import</span> <span class="n">LabelExtension</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [3]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># Read the example catalog</span>
<span class="n">root_catalog</span> <span class="o">=</span> <span class="n">Catalog</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="s1">'public/example-catalog/catalog.json'</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Explore-the-High-Level-Catalog-Information">Explore the High-Level Catalog Information<a class="anchor-link" href="#Explore-the-High-Level-Catalog-Information">¶</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To give us an idea of how the catalog we are working with is organized, let's take a look at all elements of the STAC using the <code>describe</code> method.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<div style="background-color:rgba(181, 216, 229, 0.8); text-align:center; vertical-align: top; padding:10px; ml:5px; 0;">
NOTE: Be careful using the `describe` method on large catalogs, as it will walk and print the entire tree of the STAC.
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [4]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">root_catalog</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>* <Catalog id=landsat-stac-collection-catalog>
* <Collection id=landsat-8-l1>
* <Item id=LC80140332018166LGN00>
* <Item id=LC80150322018141LGN00>
* <Item id=LC80150332018189LGN00>
* <Item id=LC80300332018166LGN00>
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>From this output, we can see that the catalog has 1 collection and that this collection has 4 items.</p>
<p>Now, let's look at the root catalog more in depth.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [5]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># Print some basic metadata from the Catalog</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ID: </span><span class="si">{</span><span class="n">root_catalog</span><span class="o">.</span><span class="n">id</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Title: </span><span class="si">{</span><span class="n">root_catalog</span><span class="o">.</span><span class="n">title</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'N/A'</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Description: </span><span class="si">{</span><span class="n">root_catalog</span><span class="o">.</span><span class="n">description</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'N/A'</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>ID: landsat-stac-collection-catalog
Title: STAC for Landsat data
Description: STAC for Landsat data
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<div style="background-color:rgba(181, 216, 229, 0.8); text-align:center; vertical-align: top; padding:10px; ml:5px; 0;">
Note: we do not print the "stac_version" here. PySTAC automatically updates any catalogs to the most recent supported STAC version and will automatically write this to the JSON object during serialization.
</div><p>Let's confirm the latest STAC Specification version supported by PySTAC.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [6]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">get_stac_version</span><span class="p">())</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>1.0.0
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>With this information, we have an understanding of the layout and general information about the STAC Catalog at hand. Now, let's dive deeper into this catalog.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Crawl-STAC-Child-Catalogs-and/or-Collections">Crawl STAC Child Catalogs and/or Collections<a class="anchor-link" href="#Crawl-STAC-Child-Catalogs-and/or-Collections">¶</a></h2><p><a href="https://github.com/radiantearth/stac-spec/tree/master/collection-spec">STAC Collections</a> are used to group related items and provide aggregate or summary metadata for those items.</p>
<p>STAC Catalogs may have many nested layers of catalogs or collections within the top-level collection. Our example catalog only has one collection within the main catalog at <a href="/public/example-catalog/landsat-8-l1/collection.json">landsat-8-l1/collection.json</a>. We can list the collections in a given catalog using the <code>Catalog.get_collections</code> method. This method returns an iterable of PySTAC <a href="https://pystac.readthedocs.io/en/latest/api.html#collection">Collection</a> instances, which we will turn into a <code>list</code>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [7]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">collections</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">root_catalog</span><span class="o">.</span><span class="n">get_collections</span><span class="p">())</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Number of collections: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">collections</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Collections IDs:"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">collection</span> <span class="ow">in</span> <span class="n">collections</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"- </span><span class="si">{</span><span class="n">collection</span><span class="o">.</span><span class="n">id</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>Number of collections: 1
Collections IDs:
- landsat-8-l1
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Let's grab that collection as a PySTAC <a href="https://pystac.readthedocs.io/en/latest/api/collection.html#pystac-collection">Collection</a> instance using the <code>Catalog.get_child</code> method so we can look at it in more detail. This method gets a child catalog or collection by ID, so we'll use the collection ID that we printed above. Since this method returns <code>None</code> if no child exists with the given ID, let's check to make sure we actually got the <code>Collection</code>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [8]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">collection</span> <span class="o">=</span> <span class="n">root_catalog</span><span class="o">.</span><span class="n">get_child</span><span class="p">(</span><span class="s2">"landsat-8-l1"</span><span class="p">)</span>
<span class="k">if</span> <span class="n">collection</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Collection is Empty. Check your downloads and try agian."</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Collection has a root child. You may proceed to the following steps."</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>Collection has a root child. You may proceed to the following steps.
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Crawl-the-STAC-Items">Crawl the STAC Items<a class="anchor-link" href="#Crawl-the-STAC-Items">¶</a></h2><p><a href="https://github.com/radiantearth/stac-spec/tree/master/item-spec">STAC Items</a> are the fundamental building blocks of a STAC Catalog. Each Item represents a single spatiotemporal resource (e.g. a satellite scene).</p>
<p>Both catalogs and collections may have items associated with them. Let's crawl our catalog, starting at the root, to see what Items we have. The <code>Catalog.get_all_items</code> method provides a convenient way of recursively listing all Items associated with a catalog and all of its sub-catalogs.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [9]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">items</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">root_catalog</span><span class="o">.</span><span class="n">get_all_items</span><span class="p">())</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Number of items: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">items</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">items</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"- </span><span class="si">{</span><span class="n">item</span><span class="o">.</span><span class="n">id</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>Number of items: 4
- LC80140332018166LGN00
- LC80150322018141LGN00
- LC80150332018189LGN00
- LC80300332018166LGN00
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>These IDs are not very descriptive; in the next section, we will see how we can access the rich metadata associated with each item.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Explore-STAC-Item-Metadata">Explore STAC Item Metadata<a class="anchor-link" href="#Explore-STAC-Item-Metadata">¶</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Item-Metadata">Item Metadata<a class="anchor-link" href="#Item-Metadata">¶</a></h3><p>Items can have <em>a lot</em> of metadata. This can be a bit overwhelming at first, but let's break the metadata fields down into a few categories:</p>
<ol>
<li>Core Item Metadata</li>
<li>Common Metadata</li>
<li>STAC Extensions</li>
</ol>
<p>We will walk through each of these metadata categories in the following sections.</p>
<p>First, let's grab one of the Items using the <code>Catalog.get_item</code> method. We will use <code>recursive=True</code> to recursively crawl all child catalogs and/or collections to find the item.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [10]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">item</span> <span class="o">=</span> <span class="n">root_catalog</span><span class="o">.</span><span class="n">get_item</span><span class="p">(</span><span class="s2">"LC80140332018166LGN00"</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="1.-Core-Item-Metadata">1. Core Item Metadata<a class="anchor-link" href="#1.-Core-Item-Metadata">¶</a></h4><p>The core item metadata fields include spatiotemporal information and the ID of the collection to which the item belongs. These fields are all at the top level of the item JSON and we can access them through attributes on the <a href="https://pystac.readthedocs.io/en/latest/api/collection.html#pystac-collection">PySTAC Item</a> instance.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [11]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">item</span><span class="o">.</span><span class="n">geometry</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[11]:</div>
<div class="output_text output_subarea output_execute_result">
<pre>{'type': 'Polygon',
'coordinates': [[[-76.12180471942207, 39.95810181489563],
[-73.94910518227414, 39.55117185146004],
[-74.49564725552679, 37.826064511480496],
[-76.66550404911956, 38.240699151776084],
[-76.12180471942207, 39.95810181489563]]]}</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [12]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">item</span><span class="o">.</span><span class="n">bbox</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[12]:</div>
<div class="output_text output_subarea output_execute_result">
<pre>[-76.66703, 37.82561, -73.94861, 39.95958]</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [13]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">item</span><span class="o">.</span><span class="n">datetime</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[13]:</div>
<div class="output_text output_subarea output_execute_result">
<pre>datetime.datetime(2018, 6, 15, 15, 39, 9, tzinfo=tzutc())</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [14]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">item</span><span class="o">.</span><span class="n">collection_id</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[14]:</div>
<div class="output_text output_subarea output_execute_result">
<pre>'landsat-8-l1'</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>We can also access the same information as the cell above by running the <code>Item.get_collection</code> method.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [15]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">item</span><span class="o">.</span><span class="n">get_collection</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[15]:</div>
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.pystac-summary {
cursor: pointer;
display:list-item;
}
.pystac-key {
color: rgb(0, 128, 0);
font-weight: 700;
}
.pystac-key-value {
display: inline-block;
margin: 0px 0.5em 0px 0px;
}
</style>
<div class="jp-RenderedJSON jp-mod-trusted jp-OutputArea-output">
<div class="container" style="line-height: normal;">
<ul style="padding: 0px; margin: 0px; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">type</span>
<span style="color: rgb(186, 33, 33);">"Collection"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">id</span>
<span style="color: rgb(186, 33, 33);">"landsat-8-l1"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">stac_version</span>
<span style="color: rgb(186, 33, 33);">"1.0.0"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">description</span>
<span style="color: rgb(186, 33, 33);">"Landsat 8 imagery radiometrically calibrated and orthorectified using ground points and Digital Elevation Model (DEM) data to correct relief displacement."</span>
</li>
<li><details>
<summary class="pystac-summary">
<span class="pystac-key">links</span>
<span style="padding-left: 0.5em; color: rgb(64, 128, 128); font-style: italic;">[] 7 items</span>
</summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">0</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"root"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/catalog.json"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">type</span>
<span style="color: rgb(186, 33, 33);">"application/json"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">title</span>
<span style="color: rgb(186, 33, 33);">"STAC for Landsat data"</span>
</li>
</ul>
</details></li>
</ul>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">1</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"item"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/landsat-8-l1/2018-06/LC80140332018166LGN00.json"</span>
</li>
</ul>
</details></li>
</ul>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">2</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"item"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/landsat-8-l1/2018-05/LC80150322018141LGN00.json"</span>
</li>
</ul>
</details></li>
</ul>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">3</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"item"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/landsat-8-l1/2018-07/LC80150332018189LGN00.json"</span>
</li>
</ul>
</details></li>
</ul>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">4</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"item"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/landsat-8-l1/2018-06/LC80300332018166LGN00.json"</span>
</li>
</ul>
</details></li>
</ul>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">5</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"self"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/landsat-8-l1/collection.json"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">type</span>
<span style="color: rgb(186, 33, 33);">"application/json"</span>
</li>
</ul>
</details></li>
</ul>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li><details>
<summary class="pystac-summary"><span class="pystac-key">6</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">rel</span>
<span style="color: rgb(186, 33, 33);">"parent"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">href</span>
<span style="color: rgb(186, 33, 33);">"/Users/michelleroby/radiant-earth/stac-site/notebooks/src/public/example-catalog/catalog.json"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">type</span>
<span style="color: rgb(186, 33, 33);">"application/json"</span>
</li>
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">title</span>
<span style="color: rgb(186, 33, 33);">"STAC for Landsat data"</span>
</li>
</ul>
</details></li>
</ul>
</details></li>
<li><details>
<summary class="pystac-summary">
<span class="pystac-key">stac_extensions</span>
<span style="padding-left: 0.5em; color: rgb(64, 128, 128); font-style: italic;">[] 1 items</span>
</summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">0</span>
<span style="color: rgb(186, 33, 33);">"https://example.com/stac/landsat-extension/1.0/schema.json"</span>
</li>
</ul>
</details></li>
<li><details>
<summary class="pystac-summary"><span class="pystac-key">properties</span></summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">collection</span>
<span style="color: rgb(186, 33, 33);">"landsat-8-l1"</span>
</li>
<li><details>
<summary class="pystac-summary">
<span class="pystac-key">instruments</span>
<span style="padding-left: 0.5em; color: rgb(64, 128, 128); font-style: italic;">[] 1 items</span>
</summary>
<ul style="margin: 0px; padding: 0px 0px 0px 1.75em; list-style: none; display: block;">
<li style="overflow-wrap: break-word; padding-left: 2.125em; text-indent: -0.5em;">
<span class="pystac-key pystac-key-value">0</span>
<span style="color: rgb(186, 33, 33);">"OLI_TIRS"</span>
</li>
</ul>
</details></li>