Skip to content

Empty geometries not all created the same way #742

@mwtoews

Description

@mwtoews

Currently there are two ways to create an empty geometry (e.g. Polygon):

from shapely import wkt
from shapely.geometry import mapping, Polygon

# Method 1: using an empty constructor
g1 = Polygon()
print('{}, {}, {}'.format(mapping(g1), g1.geom_type, g1.wkt))
# {'type': 'Polygon', 'coordinates': ()}, GeometryCollection, GEOMETRYCOLLECTION EMPTY

# Method 2: loading empty WKT
g2 = wkt.loads('POLYGON EMPTY')
print('{}, {}, {}'.format(mapping(g2), g2.geom_type, g2.wkt))
# {'type': 'Polygon', 'coordinates': ()}, Polygon, POLYGON EMPTY

(all other geometry types behave the same way).

In both cases, the Python objects know they are Polygons based on the Python object type. However the GEOS objects (referenced by ._geom) are either GeometryCollection or Polygon, based on how the geometries were constructed. This seems inconsistent to me, as I'd expect the two methods to be identical.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions