Skip to content

Commit

Permalink
Merge pull request #1007 from koordinates/drop-empty-geometry-features
Browse files Browse the repository at this point in the history
Adds a --drop-empty-geometry-features option to kart export
  • Loading branch information
olsen232 authored Oct 23, 2024
2 parents cee2566 + 2a67b6b commit c59deb4
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 c59deb4

Please sign in to comment.