From 42faa08f12ca490c89a697e9aed1af8ec2e09cee Mon Sep 17 00:00:00 2001 From: Phil Varner Date: Mon, 27 Nov 2023 08:34:43 -0500 Subject: [PATCH] =?UTF-8?q?remove=20thumbnail=20asset=20hrefing=20preview.?= =?UTF-8?q?jpg=20as=20this=20asset=20is=20not=20alway=E2=80=A6=20(#144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove thumbnail asset hrefing preview.jpg as this asset is not always there * changelog --- CHANGELOG.MD | 2 ++ src/stactools/sentinel2/constants.py | 2 -- src/stactools/sentinel2/stac.py | 12 ------------ .../expected_output.json | 8 -------- .../expected_output.json | 8 -------- .../expected_output.json | 8 -------- .../expected_output.json | 8 -------- 7 files changed, 2 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 36e6a2f..aee2b8f 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -30,6 +30,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - pystac >= 1.9.0 is now required - Names in eo:bands structure are now S2 band names, not common name ([#139](https://github.com/stactools-packages/sentinel2/pull/139)) - PVI asset role changed from "thumbnail" or "visual" to "overview" ([#143](https://github.com/stactools-packages/sentinel2/pull/143)) +- Removed asset "thumbnail" pointing to preview.jpg asset, as this file frequently + does not exit. ([#144](https://github.com/stactools-packages/sentinel2/pull/144)) ### Removed diff --git a/src/stactools/sentinel2/constants.py b/src/stactools/sentinel2/constants.py index fb5a5a5..54bcc79 100644 --- a/src/stactools/sentinel2/constants.py +++ b/src/stactools/sentinel2/constants.py @@ -171,7 +171,6 @@ } L2A_IMAGE_PATHS: Final[list[str]] = [ - "preview.jpg", "R10m/B04.jp2", "R10m/B03.jp2", "R10m/B02.jp2", @@ -215,7 +214,6 @@ ] L1C_IMAGE_PATHS: Final[list[str]] = [ - "preview.jpg", "B01.jp2", "B02.jp2", "B03.jp2", diff --git a/src/stactools/sentinel2/stac.py b/src/stactools/sentinel2/stac.py index d3f6296..fab162a 100644 --- a/src/stactools/sentinel2/stac.py +++ b/src/stactools/sentinel2/stac.py @@ -61,7 +61,6 @@ SCL_PATTERN: Final[Pattern[str]] = re.compile(r"[_/]SCL[_.]") CLD_PATTERN: Final[Pattern[str]] = re.compile(r"[_/]CLD[_.]") SNW_PATTERN: Final[Pattern[str]] = re.compile(r"[_/]SNW[_.]") -THUMBNAIL_PATTERN: Final[Pattern[str]] = re.compile(r"[_/]preview[_.]") BAND_PATTERN: Final[Pattern[str]] = re.compile(r"[_/](B\w{2})") IS_TCI_PATTERN: Final[Pattern[str]] = re.compile(r"[_/]TCI") @@ -271,7 +270,6 @@ def image_asset_from_href( raise Exception(f"Must supply a media type for asset : {asset_href}") # Handle preview image - if "_PVI" in asset_href: asset = pystac.Asset( href=asset_href, @@ -283,16 +281,6 @@ def image_asset_from_href( asset_eo.bands = RGB_BANDS return "preview", asset - elif THUMBNAIL_PATTERN.search(asset_href): - # thumbnail image - asset = pystac.Asset( - href=asset_href, - media_type=pystac.MediaType.JPEG, - title="Thumbnail image", - roles=["thumbnail"], - ) - return "thumbnail", asset - # Extract gsd and proj info resolution = extract_gsd(asset_href) if resolution is None: diff --git a/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json b/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json index 3e5c157..63e49ab 100644 --- a/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json @@ -74,14 +74,6 @@ } ], "assets": { - "thumbnail": { - "href": "./preview.jpg", - "type": "image/jpeg", - "title": "Thumbnail image", - "roles": [ - "thumbnail" - ] - }, "coastal": { "href": "./B01.jp2", "type": "image/jp2", diff --git a/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json b/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json index 21fc5d1..64cc19a 100644 --- a/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json @@ -86,14 +86,6 @@ } ], "assets": { - "thumbnail": { - "href": "./preview.jpg", - "type": "image/jpeg", - "title": "Thumbnail image", - "roles": [ - "thumbnail" - ] - }, "red": { "href": "./R10m/B04.jp2", "type": "image/jp2", diff --git a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json index 98271a2..957002b 100644 --- a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json @@ -86,14 +86,6 @@ } ], "assets": { - "thumbnail": { - "href": "./preview.jpg", - "type": "image/jpeg", - "title": "Thumbnail image", - "roles": [ - "thumbnail" - ] - }, "red": { "href": "./R10m/B04.jp2", "type": "image/jp2", diff --git a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json index 098f4f5..3a499df 100644 --- a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json @@ -92,14 +92,6 @@ } ], "assets": { - "thumbnail": { - "href": "./preview.jpg", - "type": "image/jpeg", - "title": "Thumbnail image", - "roles": [ - "thumbnail" - ] - }, "red": { "href": "./R10m/B04.jp2", "type": "image/jp2",