Skip to content
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

Deprecate the label extension #1270

Merged
merged 1 commit into from
Oct 23, 2023
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
5 changes: 4 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ exclude_lines =
[run]
branch = true
source =
pystac
pystac
omit =
pystac/extensions/label.py

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

- `ExtensionManagementMixin.validate_has_extension` is replaced with `ExtensionManagementMixin.ensure_has_extension`. Calling `ExtensionManagementMixin.validate_has_extension` will raise a `DeprecationWarning` and call `ExtensionManagementMixin.ensure_has_extension` ([#1248](https://github.com/stac-utils/pystac/pull/1248))
- `validate_all` for dicts; use `validate_all_dict` instead ([#1246](https://github.com/stac-utils/pystac/pull/1246))
- `Label` extension ([#1270](https://github.com/stac-utils/pystac/pull/1270))

## [v1.8.4] - 2023-09-22

Expand Down
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ PySTAC provides support for the following STAC Extensions:
* :mod:`Electro-Optical <pystac.extensions.eo>`
* :mod:`File Info <pystac.extensions.file>`
* :mod:`Item Assets <pystac.extensions.item_assets>`
* :mod:`Label <pystac.extensions.label>`
* :mod:`MGRS <pystac.extensions.mgrs>`
* :mod:`Point Cloud <pystac.extensions.pointcloud>`
* :mod:`Projection <pystac.extensions.projection>`
Expand Down
1 change: 0 additions & 1 deletion docs/api/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pystac.extensions
file.FileExtension
grid.GridExtension
item_assets.ItemAssetsExtension
label.LabelExtension
mgrs.MgrsExtension
pointcloud.PointcloudExtension
projection.ProjectionExtension
Expand Down
6 changes: 0 additions & 6 deletions docs/api/extensions/label.rst

This file was deleted.

39 changes: 8 additions & 31 deletions docs/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -681,44 +681,25 @@ Mapping over Items
------------------

The :func:`Catalog.map_items <pystac.Catalog.map_items>` method is useful for
into smaller chunks (e.g. tiling out large image items).
item, you can return multiple items, in case you are generating new objects, or splitting items
manipulating items in a STAC. This will create a full copy of the STAC, so will leave
the original catalog unmodified. In the method that manipulates and returns the modified
item, you can return multiple items, in case you are generating new objects (e.g.
creating a :class:`~pystac.LabelItem` for image items in a stac), or splitting items
into smaller chunks (e.g. tiling out large image items).

.. code-block:: python

def modify_item_title(item):
item.title = 'Some new title'
return item

def create_label_item(item):
# Assumes the GeoJSON labels are in the
# same location as the image
img_href = item.assets['ortho'].href
label_href = '{}.geojson'.format(os.path.splitext(img_href)[0])
label_item = LabelItem(id='Labels',
geometry=item.geometry,
bbox=item.bbox,
datetime=datetime.utcnow(),
properties={},
label_description='labels',
label_type='vector',
label_properties='label',
label_classes=[
LabelClasses(classes=['one', 'two'],
name='label')
],
label_tasks=['classification'])
label_item.add_source(item, assets=['ortho'])
label_item.add_geojson_labels(label_href)

return [item, label_item]
def duplicate_item(item):
duplicated_item = item.clone()
duplicated_item.id += "-duplicated"
return [item, duplicated_item]


c = catalog.map_items(modify_item_title)
c = c.map_items(create_label_item)
c = c.map_items(duplicate_item)
new_catalog = c

.. _copy stacs:
Expand All @@ -731,11 +712,7 @@ and mutations of STAC data. The :func:`STACObject.full_copy
<pystac.STACObject.full_copy>` mechanism handles this in a way that ties the elements of
the copies STAC together correctly. This includes situations where there might be cycles
in the graph of connected objects of the STAC (which otherwise would be `a tree
<https://en.wikipedia.org/wiki/Tree_(graph_theory)>`_). For example, if a
:class:`~pystac.LabelItem` lists a :attr:`~pystac.LabelItem.source` that is an item also
contained in the root catalog; the full copy of the STAC will ensure that the
:class:`~pystac.Item` instance representing the source imagery item is the same instance
that is linked to by the :class:`~pystac.LabelItem`.
<https://en.wikipedia.org/wiki/Tree_(graph_theory)>`_).

Resolving STAC objects
======================
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ How to create STAC Catalogs with PySTAC
This was a tutorial that was part of a 30 minute presentation at the `community STAC
sprint
<https://github.com/radiantearth/community-sprints/tree/master/11052019-arlignton-va>`_
in Arlington, VA in November 2019. It runs through creating a STAC of image or label
items from the `SpaceNet 5 <https://www.topcoder.com/challenges/30099956>`_ dataset.
in Arlington, VA in November 2019. It runs through creating a STAC of images
from the `SpaceNet 5 <https://www.topcoder.com/challenges/30099956>`_ dataset.

Creating a Landsat 8 STAC
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/creating-a-landsat-stac.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.1"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
Loading