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:
- add a parameter to
from_wkb that would allow invalid geometries to be returned as None, and raise a warning
- 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.
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:
from_wkbthat would allow invalid geometries to be returned asNone, and raise a warningNoneand 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
Nonegeometries 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.