Skip to content

Commit

Permalink
Adds a --drop-empty-geometry-features option to kart export
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed Oct 23, 2024
1 parent cee2566 commit 2a67b6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _When adding new entries to the changelog, please include issue/PR numbers where
## Unreleased

- Upgrade to PDAL 2.7 [#1005](https://github.com/koordinates/kart/pull/1005)
- Adds a `--drop-empty-geometry-features` option to `kart export`. [#1007](https://github.com/koordinates/kart/pull/1007)

## 0.15.3

Expand Down
8 changes: 8 additions & 0 deletions kart/tabular/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ def get_driver(destination_spec):
is_flag=True,
help="Skips export of those features where the geometry is null.",
)
@click.option(
"--drop-empty-geometry-features",
is_flag=True,
help='Skips export of those features where the geometry is either null or empty, such as "POLYGON EMPTY".',
)
@click.option(
"--drop-geometry",
"drop_geometry_column",
Expand All @@ -176,6 +181,7 @@ def table_export(
primary_key_as_fid,
override_geometry_type,
drop_null_geometry_features,
drop_empty_geometry_features,
drop_geometry_column,
args,
):
Expand Down Expand Up @@ -285,6 +291,8 @@ def table_export(
geom = feature[geom_key]
if geom is None and drop_null_geometry_features:
continue
if (geom is None or geom.is_empty()) and drop_empty_geometry_features:
continue
out_feature.SetGeometry(
_output_geometry(geom, geometry_transform, pk_value)
)
Expand Down

0 comments on commit 2a67b6b

Please sign in to comment.