Skip to content

Commit

Permalink
Use reproject_shape (#9)
Browse files Browse the repository at this point in the history
* fix: use reproject_shape

* chore: update CHANGELOG
  • Loading branch information
gadomski authored Sep 27, 2023
1 parent 108cdc0 commit a573c31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

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/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Use `reproject_shape` instead of `reproject_geom` ([#9](https://github.com/stactools-packages/pointcloud/pull/9))

[Unreleased]: <https://github.com/stactools-packages/ephemeral/tree/main/>
16 changes: 8 additions & 8 deletions src/stactools/pointcloud/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pystac import Asset, Item
from pystac.extensions.pointcloud import PointcloudExtension, Schema, Statistic
from pystac.extensions.projection import ProjectionExtension
from shapely.geometry import box, mapping, shape
from stactools.core.projection import reproject_geom
from shapely.geometry import box, mapping
from stactools.core.projection import reproject_shape


def create_item(
Expand Down Expand Up @@ -62,17 +62,17 @@ def create_item(
spatialreference = CRS.from_string(metadata["spatialreference"])
original_bbox = box(metadata["minx"], metadata["miny"], metadata["maxx"],
metadata["maxy"])
geometry = reproject_geom(spatialreference,
"EPSG:4326",
mapping(original_bbox),
precision=6)
bbox = list(shape(geometry).bounds)
geometry = reproject_shape(spatialreference,
"EPSG:4326",
original_bbox,
precision=6)
bbox = geometry.bounds
dt = datetime.datetime(
metadata["creation_year"], 1,
1) + datetime.timedelta(metadata["creation_doy"] - 1)

item = Item(id=id,
geometry=geometry,
geometry=mapping(geometry),
bbox=bbox,
datetime=dt,
properties={})
Expand Down

0 comments on commit a573c31

Please sign in to comment.