Skip to content

Update docs, tests, summaries for stable extensions #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Summaries for View Geometry, Projection, and Scientific extensions ([#372](https://github.com/stac-utils/pystac/pull/372))
- Raster extension support ([#364](https://github.com/stac-utils/pystac/issues/364))
- solar_illumination field in eo extension ([#356](https://github.com/stac-utils/pystac/issues/356))
- Added `Link.canonical` static method for creating links with "canonical" rel type ([#351](https://github.com/stac-utils/pystac/pull/351))
Expand Down
90 changes: 74 additions & 16 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,63 @@ PointcloudItemExt
Projection Extension
--------------------

Implements the `Projection Extension <https://github.com/radiantearth/stac-spec/tree/v1.0.0-beta.2/extensions/projection>`_.
These classes are representations of the :stac-ext:`Projection Extension Spec
<projection>`.

ProjectionItemExt
~~~~~~~~~~~~~~~~~
ProjectionExtension
~~~~~~~~~~~~~~~~~~~

**TEMPORARILY REMOVED**
.. autoclass:: pystac.extensions.projection.ProjectionExtension
:members:
:show-inheritance:

.. .. autoclass:: pystac.extensions.projection.ProjectionItemExt
.. :members:
.. :undoc-members:
.. :show-inheritance:
ItemProjectionExtension
~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.projection.ItemProjectionExtension
:members:
:show-inheritance:

AssetProjectionExtension
~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.projection.AssetProjectionExtension
:members:
:show-inheritance:

Scientific Extension
--------------------

These classes are representations of the :stac-ext:`Scientific Extension Spec
<scientific>`.

Publication
~~~~~~~~~~~

.. autoclass:: pystac.extensions.scientific.Publication
:members:
:show-inheritance:

ScientificExtension
~~~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.scientific.ScientificExtension
:members:
:show-inheritance:

CollectionScientificExtension
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.scientific.CollectionScientificExtension
:members:
:show-inheritance:

ItemScientificExtension
~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.scientific.ItemScientificExtension
:members:
:show-inheritance:

Timestamps Extension
--------------------
Expand Down Expand Up @@ -462,17 +508,29 @@ VersionItemExt
View Geometry Extension
-----------------------

Implements the :stac-ext:`View Geometry Extension <view>`.
These classes are representations of the :stac-ext:`View Geometry Extension Spec
<view>`.

ViewItemExt
~~~~~~~~~~~
ViewExtension
~~~~~~~~~~~~~

**TEMPORARILY REMOVED**
.. autoclass:: pystac.extensions.view.ViewExtension
:members:
:show-inheritance:

.. .. autoclass:: pystac.extensions.view.ViewItemExt
.. :members:
.. :undoc-members:
.. :show-inheritance:
ItemViewExtension
~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.view.ItemViewExtension
:members:
:show-inheritance:

AssetViewExtension
~~~~~~~~~~~~~~~~~~

.. autoclass:: pystac.extensions.view.AssetViewExtension
:members:
:show-inheritance:

Serialization
-------------
Expand Down
34 changes: 22 additions & 12 deletions pystac/extensions/eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
T = TypeVar("T", pystac.Item, pystac.Asset)

SCHEMA_URI: str = "https://stac-extensions.github.io/eo/v1.0.0/schema.json"
PREFIX: str = "eo:"

BANDS_PROP: str = "eo:bands"
CLOUD_COVER_PROP: str = "eo:cloud_cover"
# Field names
BANDS_PROP: str = PREFIX + "bands"
CLOUD_COVER_PROP: str = PREFIX + "cloud_cover"


class Band:
Expand Down Expand Up @@ -277,19 +279,25 @@ class EOExtension(
Generic[T], PropertiesExtension, ExtensionManagementMixin[pystac.Item]
):
"""An abstract class that can be used to extend the properties of an
:class:`~pystac.Item` with properties from the :stac-ext:`Electro-Optical
Extension <eo>`. This class is generic over the type of STAC Object to be
extended (e.g. :class:`~pystac.Item`, :class:`~pystac.Collection`).
:class:`~pystac.Item` or :class:`~pystac.Collection` with properties from the
:stac-ext:`Electro-Optical Extension <eo>`. This class is generic over the type of
STAC Object to be extended (e.g. :class:`~pystac.Item`,
:class:`~pystac.Collection`).

This class will generally not be used directly. Instead, use the concrete
implementation associated with the STAC Object you want to extend (e.g.
:class:`~ItemEOExtension` to extend an :class:`~pystac.Item`).
To create a concrete instance of :class:`EOExtension`, use the
:meth:`EOExtension.ext` method. For example:

.. code-block:: python

>>> item: pystac.Item = ...
>>> view_ext = ViewExtension.ext(item)
"""

def apply(
self, bands: Optional[List[Band]] = None, cloud_cover: Optional[float] = None
) -> None:
"""Applies label extension properties to the extended Item.
"""Applies label extension properties to the extended :class:`~pystac.Item` or
:class:`~pystac.Collection`.

Args:
bands : A list of available bands where each item is a :class:`~Band`
Expand Down Expand Up @@ -447,8 +455,8 @@ class SummariesEOExtension(SummariesExtension):

@property
def bands(self) -> Optional[List[Band]]:
"""Get or sets a list of :class:`~pystac.Band` objects that represent
the available bands.
"""Get or sets the summary of :attr:`EOExtension.bands` values
for this Collection.
"""

return map_opt(
Expand All @@ -462,7 +470,9 @@ def bands(self, v: Optional[List[Band]]) -> None:

@property
def cloud_cover(self) -> Optional[RangeSummary[float]]:
"""Get or sets the range of cloud cover from the summary."""
"""Get or sets the summary of :attr:`EOExtension.cloud_cover` values
for this Collection.
"""
return self.summaries.get_range(CLOUD_COVER_PROP)

@cloud_cover.setter
Expand Down
5 changes: 2 additions & 3 deletions pystac/extensions/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
class LabelRelType(str, Enum):
"""A list of rel types defined in the Label Extension.

See the`Label Extension Links
<https://github.com/stac-extensions/label#links-source-imagery>`__ documentation
for details.
See the :stac-ext:`Label Extension Links <label#links-source-imagery>`
documentation for details.
"""

def __str__(self) -> str:
Expand Down
Loading