Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take coverage weights in account when generating statistics from GeoJSON features #705

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading