Skip to content

Handle missing indices in geometry+index constructors #345

@caspervdw

Description

@caspervdw

We currently have mixed behaviour on the handling of missing indices in the geometry creation functions.

I'd like to decide on this and make it consistent. This already arised in #322.

Do we want this?

>>> pygeos.linestrings([[0.1, 0.1], [0.2, 0.2]], indices=[1, 1])
[None, Geometry("LINESTRING (0.1 0.1, 0.2 0.2)")]

Or this?

pygeos.multipoints([pygeos.Geometry("POINT (1 1)")] * 2, indices=[1, 1])
>>> array([<pygeos.Geometry MULTIPOINT EMPTY>,
                 <pygeos.Geometry MULTIPOINT (1 1, 1 1)>], dtype=object)

We basically have 3 options:

  • raise an exception (like what is done when you supply 1 coordinate for a linestring)
  • insert an EMPTY geometry (but; LINEARRING EMPTY does not exist, so what to do there?)
  • insert a None

I am tending towards the first option. It is always better to make it more strict, then you can keep backwards compatibility when changing it later. What do you think @jorisvandenbossche @brendan-ward ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions