Skip to content

Geometry types

The seven typed geometry classes and the members unique to each type. Shared operations live on Geometry.

Related: Geometry

Point

Accepted call forms
Point(x: None = None, y: None = None, *, z: None = None, m: None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Point
Point(x: Point | Iterable[float], y: None = None, *, z: FloatScalar | ScalarFloatArray | None = None, m: FloatScalar | ScalarFloatArray | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Point
Point(x: FloatScalar | ScalarFloatArray, y: FloatScalar | ScalarFloatArray, *, z: FloatScalar | ScalarFloatArray | None = None, m: FloatScalar | ScalarFloatArray | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Point

A single point geometry.

Parameters:

Name Type Description Default
x None | Point | Iterable[float] | FloatScalar | ScalarFloatArray

A Point to copy, one finite coordinate value, or the X coordinate. Omit both coordinates for an empty point.

varies by call form
y None | FloatScalar | ScalarFloatArray

Finite Y coordinate when x is a scalar. Omit it when x is a coordinate value or existing Point.

varies by call form
z None | FloatScalar | ScalarFloatArray | None

Z ordinate (adds a 3D dimension).

Z (elevation) ordinate, producing an XYZ or XYZM point.

None
m None | FloatScalar | ScalarFloatArray | None

M (measure) ordinate.

M (measure) ordinate, producing an XYM or XYZM point.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a Point geometry — XY, XYZ, XYM, or XYZM.

Pass one coordinate value or separate x/y scalars. A coordinate of length two, three, or four means XY, XYZ, or XYZM. Pass m= to build XYM; to build many points use points.

Returns:

Type Description
Point

A point geometry — empty when x/y are omitted.

Raises:

Type Description
InvalidGeometryError

If any coordinate is not finite.

CRSError

If epoch is set without crs, or crs is not recognized.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> gm.Point(1, 2).to_wkt()
'POINT (1 2)'
>>> gm.Point(1, 2, z=3).to_wkt()
'POINT Z (1 2 3)'
>>> gm.Point(1, 2, m=9).to_wkt()
'POINT M (1 2 9)'
>>> gm.Point((1, 2, 3, 9)).to_wkt()
'POINT ZM (1 2 3 9)'
>>> gm.Point(13.4, 52.5, crs=4326).crs
CRS("EPSG:4326")
>>> gm.Point().to_wkt()
'POINT EMPTY'

m property

m: float

M (measure) ordinate.

Returns:

Type Description
float

The M measure value; it is not converted using CRS units.

Raises:

Type Description
GeometryTypeError

If the point has no M ordinate.

AttributeError

If the point is empty (POINT EMPTY).

parts property

Lazy view over this geometry's top-level parts.

Simple geometries expose themselves as a one-row view; multipart and collection geometries expose their members. GeometryArray(geom.parts) materializes them as an array.

Returns:

Type Description
GeometryParts

x property

x: float

X coordinate of the point.

Returns:

Type Description
float

The X ordinate in the geometry's coordinate units.

Raises:

Type Description
AttributeError

If the point is empty (POINT EMPTY).

y property

y: float

Y coordinate of the point.

Returns:

Type Description
float

The Y ordinate in the geometry's coordinate units.

Raises:

Type Description
AttributeError

If the point is empty (POINT EMPTY).

z property

z: float

Z (elevation) ordinate.

Returns:

Type Description
float

The Z ordinate in the geometry's coordinate units.

Raises:

Type Description
GeometryTypeError

If the point has no Z ordinate.

AttributeError

If the point is empty (POINT EMPTY).

destination

Accepted call forms
destination(bearing: ScalarFloatArray, distance: FloatScalar | ScalarFloatArray, *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> Point
destination(bearing: FloatScalar | ScalarFloatArray, distance: ScalarFloatArray, *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> Point
destination(bearing: FloatScalar | ScalarFloatArray, distance: FloatScalar | ScalarFloatArray, *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> Point
destination(bearing: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], distance: FloatScalar | ScalarFloatArray, *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> GeometryArray[Point]
destination(bearing: FloatScalar | ScalarFloatArray, distance: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> GeometryArray[Point]
destination(bearing: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], distance: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> GeometryArray[Point]
destination(bearing: FloatInput, distance: FloatInput, *, path: Literal['geodesic'] = 'geodesic', unit: Literal['planar', 'meters'] | None = None) -> Point | GeometryArray[Point]
destination(bearing: ScalarFloatArray, distance: FloatScalar | ScalarFloatArray, *, path: Literal['rhumb'], unit: None = None) -> Point
destination(bearing: FloatScalar | ScalarFloatArray, distance: ScalarFloatArray, *, path: Literal['rhumb'], unit: None = None) -> Point
destination(bearing: FloatScalar | ScalarFloatArray, distance: FloatScalar | ScalarFloatArray, *, path: Literal['rhumb'], unit: None = None) -> Point
destination(bearing: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], distance: FloatScalar | ScalarFloatArray, *, path: Literal['rhumb'], unit: None = None) -> GeometryArray[Point]
destination(bearing: FloatScalar | ScalarFloatArray, distance: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], *, path: Literal['rhumb'], unit: None = None) -> GeometryArray[Point]
destination(bearing: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], distance: FloatColumn | ndarray[tuple[int], dtype[floating[Any] | signedinteger[Any] | unsignedinteger[Any]]], *, path: Literal['rhumb'], unit: None = None) -> GeometryArray[Point]
destination(bearing: FloatInput, distance: FloatInput, *, path: Literal['rhumb'], unit: None = None) -> Point | GeometryArray[Point]

Walk from this point along a geodesic or rhumb path. An empty point stays POINT EMPTY.

Parameters:

Name Type Description Default
bearing float or sequence of float

Initial azimuth in degrees clockwise from north.

required
distance float or sequence of float

Finite, non-negative distance to travel in CRS-natural units, unless unit is set.

required
path ('geodesic', 'rhumb')

Route model. Geodesic forms omit path; rhumb forms require path='rhumb' and a geographic CRS.

'geodesic'
unit ('planar', 'meters')

None (the default) follows the CRS: geographic shape area and length use ellipsoidal chart-edge measures while point distances use geodesics; projected measurements use native linear units, and CRS-free measurements use raw coordinate units (area results square the corresponding unit). 'planar' uses Cartesian coordinate space, with geographic coordinates in their native angular units. 'meters' uses the CRS-aware metric and requires a CRS.

path='rhumb' uses meters and does not accept a unit override.

'planar'

Returns:

Type Description
Point or GeometryArray[Point]

The destination point, or one destination per bearing or distance.

Raises:

Type Description
GeometryError

If bearing or distance is invalid.

CRSError

If the selected route requires an unavailable CRS metric.

InvalidGeometryError

If a coordinate is outside the longitude/latitude domain.

Examples:

>>> import gometry as gm
>>> point = gm.Point(0, 0, crs=4326)
>>> point.destination(90, 1000).to_wkt(precision=5)
'POINT (0.00898 0)'

MultiPoint

Accepted call forms
MultiPoint(coordinates: None = None, *, x: None = None, y: None = None, z: None = None, m: None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> MultiPoint
MultiPoint(coordinates: Iterable[Point | Iterable[float]], *, z: None = None, m: None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> MultiPoint
MultiPoint(coordinates: Iterable[Iterable[float]] | Coordinates, *, z: FloatColumn | None = None, m: FloatColumn | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> MultiPoint
MultiPoint(coordinates: None = None, *, x: FloatColumn, y: FloatColumn, z: FloatColumn | None = None, m: FloatColumn | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> MultiPoint

A collection of points.

Parameters:

Name Type Description Default
coordinates None | Iterable[Point | Iterable[float]] | Iterable[Iterable[float]] | Coordinates

The member points; omitted builds an empty multipoint.

Member coordinate tuples (x, y[, z[, m]]). Mutually exclusive with the x/y column form. Omit all inputs for an empty multipoint.

varies by call form
x None | FloatColumn

Column form: parallel ordinate arrays, one entry per point.

Per-point X and Y ordinates as parallel columns, as an alternative to coordinates. Both are required together.

varies by call form
y None | FloatColumn

Column form: parallel ordinate arrays, one entry per point.

Per-point X and Y ordinates as parallel columns, as an alternative to coordinates. Both are required together.

varies by call form
z None | FloatColumn | None

Column form: parallel ordinate arrays, one entry per point.

Per-point Z and M ordinates, as an alternative to inline tuples.

None
m None | FloatColumn | None

Column form: parallel ordinate arrays, one entry per point.

Per-point Z and M ordinates, as an alternative to inline tuples.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a MultiPoint geometry from a coordinate sequence.

Returns:

Type Description
MultiPoint

A multipoint geometry — empty when no coordinates are given.

Raises:

Type Description
InvalidGeometryError

If any coordinate is non-finite or has mixed dimensionality.

CRSError

If epoch is set without crs, or crs is not recognized.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> gm.MultiPoint([(0, 0), (1, 1)]).to_wkt()
'MULTIPOINT ((0 0), (1 1))'
>>> gm.MultiPoint().to_wkt()
'MULTIPOINT EMPTY'

parts property

The component geometries.

Returns:

Type Description
GeometryParts

A lazy view of immediate components in component order. It retains the source geometry; each component has the type declared by its owning geometry class. Scalar indexing and iteration create one typed geometry at a time, while slices return a list.

__getitem__

Accepted call forms
__getitem__(index: SupportsIndex, /) -> Point
__getitem__(index: slice, /) -> list[Point]
__getitem__(index: SupportsIndex | slice, /) -> Point | list[Point]

Select parts by integer or slice.

An int returns one component geometry. A slice returns a list of component geometries.

Returns:

Type Description
Geometry or list of Geometry

__iter__

__iter__() -> GeometryPartsIterator[Point]

Iterate component geometries.

Returns:

Type Description
iterator of Geometry

__len__

__len__() -> int

Number of component parts.

Returns:

Type Description
int

__reversed__

__reversed__() -> GeometryPartsIterator[Point]

Iterate component geometries in reverse order.

Returns:

Type Description
iterator of Geometry

count

count(value: object) -> int

Number of parts equal to value.

Parameters:

Name Type Description Default
value object

The geometry value to count.

required

Returns:

Type Description
int

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> multi.count(multi[0])
1

index

index(value: object, start: int = 0, stop: int | None = None) -> int

First index of an equal part in [start, stop).

Parameters:

Name Type Description Default
value object

The geometry value to locate.

required
start int

First position searched.

0
stop int

One past the last position searched.

None

Returns:

Type Description
int

The first matching position.

Raises:

Type Description
ValueError

If no part in the window equals value.

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> part = multi[0]
>>> multi.index(part)
0

LineString

Accepted call forms
LineString(coordinates: None = None, *, x: None = None, y: None = None, z: None = None, m: None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> LineString
LineString(coordinates: Iterable[Iterable[float]] | Coordinates, *, z: FloatColumn | None = None, m: FloatColumn | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> LineString
LineString(coordinates: None = None, *, x: FloatColumn, y: FloatColumn, z: FloatColumn | None = None, m: FloatColumn | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> LineString

A single linestring (polyline).

Parameters:

Name Type Description Default
coordinates None | Iterable[Iterable[float]] | Coordinates

The vertices as (x, y[, z, m]) tuples; omitted builds an empty line.

Ordered (x, y[, z[, m]]) tuples, or an (N, 2..4) array. Mutually exclusive with the x/y column form. Omit all inputs for an empty linestring.

varies by call form
x None | FloatColumn

Column form: parallel ordinate arrays, one entry per vertex.

Per-vertex X and Y ordinates as parallel columns, as an alternative to coordinates. Both are required together.

varies by call form
y None | FloatColumn

Column form: parallel ordinate arrays, one entry per vertex.

Per-vertex X and Y ordinates as parallel columns, as an alternative to coordinates. Both are required together.

varies by call form
z None | FloatColumn | None

Column form: parallel ordinate arrays, one entry per vertex.

Per-vertex Z and M ordinates, as an alternative to inline tuples.

None
m None | FloatColumn | None

Column form: parallel ordinate arrays, one entry per vertex.

Per-vertex Z and M ordinates, as an alternative to inline tuples.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a LineString from an ordered coordinate sequence.

Returns:

Type Description
LineString

A linestring geometry — empty when no coordinates are given.

Raises:

Type Description
InvalidGeometryError

If coordinates are non-finite, ragged, or fewer than two vertices.

CRSError

If epoch is set without crs, or crs is not recognized.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> gm.LineString([(0, 0), (1, 1)]).to_wkt()
'LINESTRING (0 0, 1 1)'
>>> gm.LineString().to_wkt()
'LINESTRING EMPTY'

parts property

Lazy view over this geometry's top-level parts.

Simple geometries expose themselves as a one-row view; multipart and collection geometries expose their members. GeometryArray(geom.parts) materializes them as an array.

Returns:

Type Description
GeometryParts

MultiLineString

Accepted call forms
MultiLineString(lines: Iterable[LineString | Iterable[Iterable[float]]] | None = None, *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> MultiLineString

A collection of linestrings.

Parameters:

Name Type Description Default
lines Iterable[LineString | Iterable[Iterable[float]]] | None

The member lines; omitted builds an empty multilinestring.

Each member is an ordered coordinate sequence (a line) or an already-built LineString. Omit for an empty multilinestring.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a MultiLineString from a sequence of line coordinate sequences.

Returns:

Type Description
MultiLineString

A multilinestring geometry — empty when lines is omitted.

Raises:

Type Description
InvalidGeometryError

If a member line has fewer than two vertices or non-finite coordinates.

CRSError

If epoch is set without crs, or crs is not recognized.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> gm.MultiLineString([[(0, 0), (1, 1)], [(2, 2), (3, 3)]]).to_wkt()
'MULTILINESTRING ((0 0, 1 1), (2 2, 3 3))'
>>> gm.MultiLineString().to_wkt()
'MULTILINESTRING EMPTY'

parts property

The component geometries.

Returns:

Type Description
GeometryParts

A lazy view of immediate components in component order. It retains the source geometry; each component has the type declared by its owning geometry class. Scalar indexing and iteration create one typed geometry at a time, while slices return a list.

__getitem__

Accepted call forms
__getitem__(index: SupportsIndex, /) -> LineString
__getitem__(index: slice, /) -> list[LineString]
__getitem__(index: SupportsIndex | slice, /) -> LineString | list[LineString]

Select parts by integer or slice.

An int returns one component geometry. A slice returns a list of component geometries.

Returns:

Type Description
Geometry or list of Geometry

__iter__

__iter__() -> GeometryPartsIterator[LineString]

Iterate component geometries.

Returns:

Type Description
iterator of Geometry

__len__

__len__() -> int

Number of component parts.

Returns:

Type Description
int

__reversed__

__reversed__() -> GeometryPartsIterator[LineString]

Iterate component geometries in reverse order.

Returns:

Type Description
iterator of Geometry

count

count(value: object) -> int

Number of parts equal to value.

Parameters:

Name Type Description Default
value object

The geometry value to count.

required

Returns:

Type Description
int

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> multi.count(multi[0])
1

index

index(value: object, start: int = 0, stop: int | None = None) -> int

First index of an equal part in [start, stop).

Parameters:

Name Type Description Default
value object

The geometry value to locate.

required
start int

First position searched.

0
stop int

One past the last position searched.

None

Returns:

Type Description
int

The first matching position.

Raises:

Type Description
ValueError

If no part in the window equals value.

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> part = multi[0]
>>> multi.index(part)
0

Polygon

Accepted call forms
Polygon(shell: None = None, holes: None = None, *, x: None = None, y: None = None, z: None = None, m: None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Polygon
Polygon(shell: Iterable[Iterable[float]] | Coordinates, holes: Iterable[Iterable[Iterable[float]] | Coordinates] | None = None, *, z: FloatColumn | None = None, m: FloatColumn | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Polygon
Polygon(shell: None = None, holes: Iterable[Iterable[Iterable[float]] | Coordinates] | None = None, *, x: FloatColumn, y: FloatColumn, z: FloatColumn | None = None, m: FloatColumn | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Polygon

A single polygon (an exterior ring with optional holes).

Parameters:

Name Type Description Default
shell None | Iterable[Iterable[float]] | Coordinates

Exterior ring vertices; omitted builds POLYGON EMPTY.

Exterior ring coordinates; closed automatically (needs ≥3 corners). Mutually exclusive with the x/y column form.

varies by call form
holes None | Iterable[Iterable[Iterable[float]] | Coordinates] | None

Interior rings, each a coordinate sequence.

Interior ring (hole) coordinate sequences, each closed automatically.

None
x None | FloatColumn

Column form for the exterior ring: parallel ordinate arrays.

Per-vertex X and Y ordinates for the exterior ring, as an alternative to shell. Both are required together.

varies by call form
y None | FloatColumn

Column form for the exterior ring: parallel ordinate arrays.

Per-vertex X and Y ordinates for the exterior ring, as an alternative to shell. Both are required together.

varies by call form
z None | FloatColumn | None

Column form for the exterior ring: parallel ordinate arrays.

Per-vertex Z and M ordinates for the exterior ring.

None
m None | FloatColumn | None

Column form for the exterior ring: parallel ordinate arrays.

Per-vertex Z and M ordinates for the exterior ring.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a Polygon from an exterior ring and optional holes.

Returns:

Type Description
Polygon

A polygon geometry.

Raises:

Type Description
InvalidGeometryError

If a ring has fewer than three corners or any coordinate is non-finite.

CRSError

If epoch is set without crs, or crs is not recognized.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> gm.Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]).to_wkt()
'POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'
>>> gm.Polygon().to_wkt()
'POLYGON EMPTY'

exterior property

exterior: LineString

Exterior ring as a closed LineString. POLYGON EMPTY returns an empty line preserving the polygon's declared axes.

Returns:

Type Description
LineString

The closed exterior ring, or an axis-preserving empty line for POLYGON EMPTY. The result retains the polygon's CRS and epoch.

interiors property

interiors: list[LineString]

Interior rings (holes), each a closed LineString. The list follows the polygon's ring order; POLYGON EMPTY has no interior rings.

Returns:

Type Description
list of LineString

A new list with one closed ring per hole, in polygon ring order. Empty polygons return an empty list. Each ring retains the polygon's declared axes, CRS, and epoch.

parts property

Lazy view over this geometry's top-level parts.

Simple geometries expose themselves as a one-row view; multipart and collection geometries expose their members. GeometryArray(geom.parts) materializes them as an array.

Returns:

Type Description
GeometryParts

MultiPolygon

Accepted call forms
MultiPolygon(polygons: Iterable[Polygon | (Iterable[Iterable[float]] | Coordinates) | Iterable[Iterable[Iterable[float]] | Coordinates]] | None = None, *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> MultiPolygon

A collection of polygons.

Parameters:

Name Type Description Default
polygons Iterable[Polygon | (Iterable[Iterable[float]] | Coordinates) | Iterable[Iterable[Iterable[float]] | Coordinates]] | None

The member polygons; omitted builds an empty multipolygon.

Each member is [shell] or [shell, *holes] of coordinate rings, or an already-built Polygon. Omit for an empty multipolygon.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a MultiPolygon from a sequence of polygons.

Returns:

Type Description
MultiPolygon

A multipolygon geometry — empty when polygons is omitted.

Raises:

Type Description
InvalidGeometryError

If any ring has fewer than three corners or non-finite coordinates.

CRSError

If epoch is set without crs, or crs is not recognized.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> left = [[(0, 0), (1, 0), (1, 1)]]
>>> right = [[(2, 2), (3, 2), (3, 3)]]
>>> len(gm.MultiPolygon([left, right]).parts)
2
>>> gm.MultiPolygon().to_wkt()
'MULTIPOLYGON EMPTY'

parts property

The component geometries.

Returns:

Type Description
GeometryParts

A lazy view of immediate components in component order. It retains the source geometry; each component has the type declared by its owning geometry class. Scalar indexing and iteration create one typed geometry at a time, while slices return a list.

__getitem__

Accepted call forms
__getitem__(index: SupportsIndex, /) -> Polygon
__getitem__(index: slice, /) -> list[Polygon]
__getitem__(index: SupportsIndex | slice, /) -> Polygon | list[Polygon]

Select parts by integer or slice.

An int returns one component geometry. A slice returns a list of component geometries.

Returns:

Type Description
Geometry or list of Geometry

__iter__

__iter__() -> GeometryPartsIterator[Polygon]

Iterate component geometries.

Returns:

Type Description
iterator of Geometry

__len__

__len__() -> int

Number of component parts.

Returns:

Type Description
int

__reversed__

__reversed__() -> GeometryPartsIterator[Polygon]

Iterate component geometries in reverse order.

Returns:

Type Description
iterator of Geometry

count

count(value: object) -> int

Number of parts equal to value.

Parameters:

Name Type Description Default
value object

The geometry value to count.

required

Returns:

Type Description
int

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> multi.count(multi[0])
1

index

index(value: object, start: int = 0, stop: int | None = None) -> int

First index of an equal part in [start, stop).

Parameters:

Name Type Description Default
value object

The geometry value to locate.

required
start int

First position searched.

0
stop int

One past the last position searched.

None

Returns:

Type Description
int

The first matching position.

Raises:

Type Description
ValueError

If no part in the window equals value.

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> part = multi[0]
>>> multi.index(part)
0

GeometryCollection

Accepted call forms
GeometryCollection(geometries: Iterable[Geometry] | None = None, *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryCollection

A heterogeneous collection of geometries.

Parameters:

Name Type Description Default
geometries Iterable[Geometry] | None

The member geometries, of any types; omitted builds an empty collection.

Member geometries; may be of mixed types. Omit for an empty collection.

None
crs CrsInput | None

Coordinate reference system, attached as metadata (never transforms coordinates).

Any supported CRS input. Declares the frame; does not transform coordinates.

None
epoch SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None

Coordinate epoch metadata; the CRS frame must admit geometry epochs.

Coordinate epoch (decimal year) for time-dependent frames.

None

Create a GeometryCollection from a sequence of geometries.

Returns:

Type Description
GeometryCollection

A geometry collection — empty when geometries is omitted.

Raises:

Type Description
TypeError

If any member is not a Geometry.

CRSError

If epoch is set without crs, or crs is not recognized.

CRSMismatchError

If members carry conflicting CRS/epoch metadata.

GeometryError

If epoch is not a finite decimal year.

Examples:

>>> import gometry as gm
>>> gc = gm.GeometryCollection([gm.Point(0, 0), gm.Point(1, 1)])
>>> gc.geometry_type
'GeometryCollection'
>>> gm.GeometryCollection().to_wkt()
'GEOMETRYCOLLECTION EMPTY'

parts property

The component geometries.

Returns:

Type Description
GeometryParts

A lazy view of immediate components in component order. It retains the source geometry; each component has the type declared by its owning geometry class. Scalar indexing and iteration create one typed geometry at a time, while slices return a list.

__getitem__

Accepted call forms
__getitem__(index: SupportsIndex, /) -> Geometry
__getitem__(index: slice, /) -> list[Geometry]
__getitem__(index: SupportsIndex | slice, /) -> Geometry | list[Geometry]

Select parts by integer or slice.

An int returns one component geometry. A slice returns a list of component geometries.

Returns:

Type Description
Geometry or list of Geometry

__iter__

__iter__() -> GeometryPartsIterator[Geometry]

Iterate component geometries.

Returns:

Type Description
iterator of Geometry

__len__

__len__() -> int

Number of component parts.

Returns:

Type Description
int

__reversed__

__reversed__() -> GeometryPartsIterator[Geometry]

Iterate component geometries in reverse order.

Returns:

Type Description
iterator of Geometry

count

count(value: object) -> int

Number of parts equal to value.

Parameters:

Name Type Description Default
value object

The geometry value to count.

required

Returns:

Type Description
int

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> multi.count(multi[0])
1

index

index(value: object, start: int = 0, stop: int | None = None) -> int

First index of an equal part in [start, stop).

Parameters:

Name Type Description Default
value object

The geometry value to locate.

required
start int

First position searched.

0
stop int

One past the last position searched.

None

Returns:

Type Description
int

The first matching position.

Raises:

Type Description
ValueError

If no part in the window equals value.

Examples:

>>> import gometry as gm
>>> multi = gm.MultiPoint([(0, 0), (1, 1)])
>>> part = multi[0]
>>> multi.index(part)
0