Skip to content

GEOS errors decoding WKB prevent reading from datasets with invalid geometries #320

@brendan-ward

Description

@brendan-ward

Various tools are using WKB as a serialization format or transport format between different binary packages (e.g., reading from GDAL as WKB, then converting to geometries here). The same is probably true for WKT.

If any of the WKB geometries are malformed, GEOS throws an error and the entire conversion fails. This makes it challenging to work with 3rd-party datasets that have invalid geometries, since these first need to be converted to geometries before they can be filtered.

We can potentially get around this in one of 2 ways:

  1. add a parameter to from_wkb that would allow invalid geometries to be returned as None, and raise a warning
  2. always return invalid geometries as None and raise a warning. This is simpler and the only API change is that it doesn't fail outright (which is likely undesirable here).

The user can then filter out the None geometries and continue with the remainder.

To be clear: for other areas where the user can actually control how geometries are constructed, it is totally appropriate to raise an exception. It is only in cases of deserializing WKB / WKT that it would be better to gracefully handle such errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions