Repository: stac-utils/pystac

Issue:
Link `item` type should be `application/geo+json`
Hi!

Pystac is not using [the **preferred** media type for link of rel `item` which should be `application/geo+json` rather than `application/json`](https://github.com/radiantearth/stac-spec/blob/master/commons/links.md#hierarchical-relations): https://github.com/stac-utils/pystac/blob/2261b55ffbac6b52e6f56434bfd5508455dc3ac6/pystac/link.py#L478
Is there a reason for that?

Thank you

Discussion:
@gadomski: Nope, probably a bug. Thanks for the report.

Solution patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1656cea..d9149839 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,6 @@
 
 ## [Unreleased]
 
-
 ### Added
 
 - Top-level `item_assets` dict on `Collection`s ([#1476](https://github.com/stac-utils/pystac/pull/1476))
@@ -14,6 +13,10 @@
 - Correctly detect absolute file path ref on windows, reflecting change in python 3.13 ([#1475](https://github.com/stac-utils/pystac/pull/14750)) (only effects python 3.13)
 - Deprecated `ItemAssetExtension` ([#1476](https://github.com/stac-utils/pystac/pull/1476))
 
+### Fixed
+
+- Use `application/geo+json` for `item` links ([#1495](https://github.com/stac-utils/pystac/pull/1495))
+
 ## [v1.11.0] - 2024-09-26
 
 ### Added
diff --git a/pystac/link.py b/pystac/link.py
index f8806109..2459c745 100644
--- a/pystac/link.py
+++ b/pystac/link.py
@@ -475,7 +475,7 @@ class Link(PathLike):
     def item(cls: type[L], item: Item, title: str | None = None) -> L:
         """Creates a link to an Item."""
         return cls(
-            pystac.RelType.ITEM, item, title=title, media_type=pystac.MediaType.JSON
+            pystac.RelType.ITEM, item, title=title, media_type=pystac.MediaType.GEOJSON
         )
 
     @classmethod


Test patch:
diff --git a/tests/test_link.py b/tests/test_link.py
index c7ecdb6c..0461a259 100644
--- a/tests/test_link.py
+++ b/tests/test_link.py
@@ -346,3 +346,9 @@ def test_is_hierarchical(rel: str) -> None:
 )
 def test_is_not_hierarchical(rel: str) -> None:
     assert not Link(rel, "a-target").is_hierarchical()
+
+
+def test_item_link_type(item: Item) -> None:
+    # https://github.com/stac-utils/pystac/issues/1494
+    link = Link.item(item)
+    assert link.media_type == "application/geo+json"