@@ -482,14 +482,15 @@ Extension <eo>`, you can access the properties associated with that extension us
482
482
import pystac
483
483
from pystac.extensions.eo import EOExtension
484
484
485
- item = Item( ... ) # See docs for creating an Item
485
+ item = pystac. Item.from_file( " tests/data-files/eo/eo-landsat-example.json " )
486
486
487
487
# Check that the Item implements the EO Extension
488
488
if EOExtension.has_extension(item):
489
489
eo_ext = EOExtension.ext(item)
490
490
491
491
bands = eo_ext.bands
492
492
cloud_cover = eo_ext.cloud_cover
493
+ snow_cover = eo_ext.snow_cover
493
494
...
494
495
495
496
.. note :: The ``ext`` method will raise an :exc:`~pystac.ExtensionNotImplemented`
@@ -511,7 +512,7 @@ can therefore mutate those properties.* For instance:
511
512
512
513
.. code-block :: python
513
514
514
- item = Item.from_file(" tests/data-files/eo/eo-landsat-example.json" )
515
+ item = pystac. Item.from_file(" tests/data-files/eo/eo-landsat-example.json" )
515
516
print (item.properties[" eo:cloud_cover" ])
516
517
# 78
517
518
@@ -563,7 +564,7 @@ extended.
563
564
.. code-block :: python
564
565
565
566
# Load a basic item without any extensions
566
- item = Item.from_file(" tests/data-files/item/sample-item.json" )
567
+ item = pystac. Item.from_file(" tests/data-files/item/sample-item.json" )
567
568
print (item.stac_extensions)
568
569
# []
569
570
@@ -575,14 +576,38 @@ extended.
575
576
Extended Summaries
576
577
------------------
577
578
578
- Extension classes like :class: `~pystac.extensions.eo.EOExtension ` may also provide a
579
- ``summaries `` static method that can be used to extend the Collection summaries. This
580
- method returns a class inheriting from
579
+ Extension classes like :class: `~pystac.extensions.projection.ProjectionExtension ` may
580
+ also provide a ``summaries `` static method that can be used to extend the Collection
581
+ summaries. This method returns a class inheriting from
581
582
:class: `pystac.extensions.base.SummariesExtension ` that provides tools for summarizing
582
583
the properties defined by that extension. These classes also hold a reference to the
583
584
Collection's :class: `pystac.Summaries ` instance in the ``summaries `` attribute.
584
585
585
- See :class: `pystac.extensions.eo.SummariesEOExtension ` for an example implementation.
586
+
587
+ .. code-block :: python
588
+
589
+ import pystac
590
+ from pystac.extensions.projection import ProjectionExtension
591
+
592
+ # Load a collection that does not implement the Projection extension
593
+ collection = pystac.Collection.from_file(
594
+ " tests/data-files/examples/1.0.0/collection.json"
595
+ )
596
+
597
+ # Add Projection extension summaries to the collection
598
+ proj = ProjectionExtension.summaries(collection, add_if_missing = True )
599
+ print (collection.stac_extensions)
600
+ # [
601
+ # ....,
602
+ # 'https://stac-extensions.github.io/projection/v1.1.0/schema.json'
603
+ # ]
604
+
605
+ # Set the values for various extension fields
606
+ proj.epsg = [4326 ]
607
+ collection_as_dict = collection.to_dict()
608
+ collection_as_dict[" summaries" ][" proj:epsg" ]
609
+ # [4326]
610
+
586
611
587
612
Item Asset properties
588
613
=====================
0 commit comments