Skip to content

Commit

Permalink
Add classification:classes to SCL asset #165
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed May 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1177bb2 commit 3e3c302
Showing 2 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project attempts to match the major and minor versions of [stactools](https://github.com/stac-utils/stactools) and increments the patch number as needed.

## [Unreleased]

### Added

- Added a `classification:classes` field to the `scl` asset (SCL).

## [0.6.4] - 2024-04-04

### Added
27 changes: 21 additions & 6 deletions src/stactools/sentinel2/stac.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import antimeridian
import pystac
from pystac.extensions.classification import Classification, ClassificationExtension
from pystac.extensions.eo import Band, EOExtension
from pystac.extensions.grid import GridExtension
from pystac.extensions.projection import ProjectionExtension
@@ -465,12 +466,26 @@ def set_asset_properties(_asset: pystac.Asset, _band_gsd: Optional[int] = None):
asset_id = mk_asset_id(maybe_res, "scl")
set_asset_properties(asset, maybe_res)

RasterExtension.ext(asset).bands = [
RasterBand.create(
nodata=0,
spatial_resolution=resolution,
data_type=DataType.UINT8,
)
band = RasterBand.create(
nodata=0,
spatial_resolution=resolution,
data_type=DataType.UINT8,
)
RasterExtension.ext(asset).bands = [band]

ClassificationExtension.ext(band).classes = [
Classification.create(0, "no_data"),
Classification.create(1, "saturated_or_defective"),
Classification.create(2, "dark_area_pixels"),
Classification.create(3, "cloud_shadows"),
Classification.create(4, "vegetation"),
Classification.create(5, "not_vegetated"),
Classification.create(6, "water"),
Classification.create(7, "unclassified"),
Classification.create(8, "cloud_medium_probability"),
Classification.create(9, "cloud_high_probability"),
Classification.create(10, "thin_cirrus"),
Classification.create(11, "snow"),
]

elif CLD_PATTERN.search(asset_href):

0 comments on commit 3e3c302

Please sign in to comment.