Skip to content

Commit

Permalink
Merge pull request #8 from stactools-packages/fix/rde/gsd
Browse files Browse the repository at this point in the history
Fix GSD bug; allow docker to test dev code inside containers
  • Loading branch information
lossyrob authored Jul 21, 2021
2 parents 3f11a74 + b1d1fea commit 520f621
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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

### Fixed

- Fix bug in assigning GSD to assets ([#8](https://github.com/stactools-packages/landsat/pull/8))


## [v0.1.7]

### Changed
Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ RUN conda install -c conda-forge pandoc

COPY . /src/stactools-landsat
RUN pip install -r /src/stactools-landsat/requirements-dev.txt

# Set the PYTHONPATH to run locally mounted source
ENV PYTHONPATH=/src/stactools-landsat/src:$PYTHONPATH

WORKDIR /src/stactools-landsat
2 changes: 1 addition & 1 deletion src/stactools/landsat/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def add_asset(self, item: pystac.Item, mtl_metadata: MtlMetadata,
# common_metadata

if self.gsd is not None:
item.common_metadata.gsd = self.gsd
pystac.CommonMetadata(asset).gsd = self.gsd
else:
if self.is_sr or self.is_qa:
sr_gsd = mtl_metadata.sr_gsd
Expand Down
18 changes: 17 additions & 1 deletion tests/test_create_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import rasterio

from stactools.core.projection import reproject_geom
from stactools.landsat.assets import SR_ASSET_DEFS, THERMAL_ASSET_DEFS
from stactools.landsat.assets import SR_ASSET_DEFS, ST_B10_ASSET_DEF, THERMAL_ASSET_DEFS
from stactools.landsat.commands import create_landsat_command
from stactools.landsat.constants import (L8_SR_BANDS, L8_SP_BANDS)
from stactools.testing import CliTestCase
Expand Down Expand Up @@ -67,6 +67,19 @@ def check_proj_bbox(item, tif_bounds):
item.validate()
self.assertEqual(item.id, item_id)

# Ensure gsd is not set on the Item,
# as it's set on the asset level

# Ensure gsd is correctly set for band 10
if ST_B10_ASSET_DEF.key in item.assets:
self.assertIn(
'gsd',
item.assets[ST_B10_ASSET_DEF.key].extra_fields)
self.assertEqual(
item.assets[
ST_B10_ASSET_DEF.key].extra_fields['gsd'],
100.0)

bands_seen = set()

for asset in item.assets.values():
Expand All @@ -76,6 +89,9 @@ def check_proj_bbox(item, tif_bounds):
if eo.bands is not None:
bands_seen |= set(b.name for b in eo.bands)

# Ensure gsd is set
self.assertIn('gsd', asset.extra_fields)

if item.properties['landsat:processing_level'] == 'L2SP':
self.assertEqual(
bands_seen,
Expand Down

0 comments on commit 520f621

Please sign in to comment.