diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b446eaa..dac863c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. ## 0.15.3 diff --git a/kart/tabular/export.py b/kart/tabular/export.py index 82845f16..9c61e661 100644 --- a/kart/tabular/export.py +++ b/kart/tabular/export.py @@ -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 empty, such as "POLYGON EMPTY".', +) @click.option( "--drop-geometry", "drop_geometry_column", @@ -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, ): @@ -285,6 +291,8 @@ def table_export( geom = feature[geom_key] if geom is None and drop_null_geometry_features: continue + if geom.is_empty() and drop_empty_geometry_features: + continue out_feature.SetGeometry( _output_geometry(geom, geometry_transform, pk_value) )