Skip to content

Commit

Permalink
round proj centroid values (#30)
Browse files Browse the repository at this point in the history
* round proj:centroid values to one decimal place, since they're always in 0.5 degree increments
  • Loading branch information
Phil Varner authored Apr 14, 2023
1 parent 8ae1c33 commit 56bb18e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [0.4.1] - 2023-04-14

### Changed

- Round `proj:centroid` values to one decimal place, since they'll always be in 0.5 degree increments([#28](https://github.com/stactools-packages/cop-dem/pull/28))

## [0.4.0] - 2023-04-14

## Added
Expand Down Expand Up @@ -48,7 +54,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- remove python 3.7 support

[Unreleased]: https://github.com/stactools-packages/cop-dem/compare/v0.4.0..main
[Unreleased]: https://github.com/stactools-packages/cop-dem/compare/v0.4.1..main
[0.4.1]: https://github.com/stactools-packages/cop-dem/compare/v0.4.0..v0.4.1
[0.4.0]: https://github.com/stactools-packages/cop-dem/compare/v0.3.0..v0.4.0
[0.3.0]: https://github.com/stactools-packages/cop-dem/compare/v0.2.0..v0.3.0
[0.2.0]: https://github.com/stactools-packages/cop-dem/compare/v0.1.1..v0.2.0
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ package_dir =
= src
packages = find_namespace:
install_requires =
stactools[s3] >= 0.4.0
stactools[s3] >= 0.4.1

[options.packages.find]
where = src
2 changes: 1 addition & 1 deletion src/stactools/cop_dem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def register_plugin(registry):
registry.register_subcommand(commands.create_cop_dem_command)


__version__ = "0.4.0"
__version__ = "0.4.1"
5 changes: 4 additions & 1 deletion src/stactools/cop_dem/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def create_item(
projection.shape = shape

centroid = make_shape(item.geometry).centroid
projection.centroid = {"lat": centroid.y, "lon": centroid.x}
projection.centroid = {
"lat": round(centroid.y, 1),
"lon": round(centroid.x, 1)
}

grid = GridExtension.ext(item, add_if_missing=True)
grid.code = f"CDEM-{northing}{easting}"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def test_create_glo90_item(self):
0.00125, 0.0, -115.000625, 0.0, -0.0008333333333333334,
54.000416666666666
])
self.assertEqual(round(projection.centroid["lat"], 5), 53.50042)
self.assertEqual(round(projection.centroid["lon"], 5), -114.50062)
self.assertEqual(round(projection.centroid["lat"], 5), 53.5)
self.assertEqual(round(projection.centroid["lon"], 5), -114.5)

grid = GridExtension.ext(item)
self.assertEqual(grid.code, "CDEM-N53W115")
Expand Down

0 comments on commit 56bb18e

Please sign in to comment.