diff --git a/stac/stac_lib.py b/stac/stac_lib.py index 6d6f83665..4aaeae82b 100644 --- a/stac/stac_lib.py +++ b/stac/stac_lib.py @@ -403,6 +403,9 @@ def get(self, item: str, default: Optional[Any] = None) -> Optional[Any]: def public_id(self) -> str: return self['id'] + def title(self) -> str: + return self.stac_json['title'] + def dataset_type(self) -> stac_checker.GeeType: return stac_checker.GeeType(self.stac_json['gee:type']) diff --git a/stac/stac_lib_test.py b/stac/stac_lib_test.py index 682845879..0a7d0ee34 100644 --- a/stac/stac_lib_test.py +++ b/stac/stac_lib_test.py @@ -83,6 +83,11 @@ def test_get_attribute(self): with self.assertRaises(KeyError): collection['does not exist'] # pylint: disable=pointless-statement + def test_get_title(self): + stac_json = _valid_stac() + collection = stac.Collection(stac_json) + self.assertEqual('A Title', collection.title()) + def test_bbox(self): stac_json = _valid_stac() stac_json['extent']['spatial'].update({'bbox': [[-1, -2, 3, 4]]})