Skip to content

Commit

Permalink
Take coverage weights in account when generating statistics from GeoJ…
Browse files Browse the repository at this point in the history
…SON features
  • Loading branch information
vincentsarago committed Sep 28, 2023
1 parent c6b5468 commit ae7a3a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

- `/crop/{width}x{height}.{format} [POST]` -> `/feature/{width}x{height}.{format} [POST]`

- update `rio-tiler` requirement to `>=6.2.1`

- Take coverage weights in account when generating statistics from GeoJSON features

## 0.14.1 (2023-09-14)

Expand Down
2 changes: 1 addition & 1 deletion src/titiler/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"numpy",
"pydantic~=2.0",
"rasterio",
"rio-tiler>=6.0,<7.0",
"rio-tiler>=6.2.1,<7.0",
"morecantile>=5.0,<6.0",
"simplejson",
"typing_extensions>=4.6.1",
Expand Down
13 changes: 11 additions & 2 deletions src/titiler/core/titiler/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,25 @@ def geojson_statistics(
with rasterio.Env(**env):
with self.reader(src_path, **reader_params) as src_dst:
for feature in fc:
shape = feature.model_dump(exclude_none=True)
data = src_dst.feature(
feature.model_dump(exclude_none=True),
shape,
shape_crs=coord_crs or WGS84_CRS,
**layer_params,
**image_params,
**dataset_params,
)

# Get the coverage % array
coverage_array = data.get_coverage_array(
shape,
shape_crs=coord_crs or WGS84_CRS,
)

stats = data.statistics(
**stats_params, hist_options={**histogram_params}
**stats_params,
hist_options={**histogram_params},
coverage=coverage_array,
)

feature.properties = feature.properties or {}
Expand Down

0 comments on commit ae7a3a4

Please sign in to comment.