Constructors & bulk factories¶
Construct geometry values and packed coordinate columns.
Related: Geometry types
box
¶
Accepted call forms
box(minx: FloatScalar | ScalarFloatArray, miny: FloatScalar | ScalarFloatArray, maxx: FloatScalar | ScalarFloatArray, maxy: FloatScalar | ScalarFloatArray, *, crs: None = None, ccw: bool = True, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Polygon
box(minx: FloatScalar | ScalarFloatArray, miny: FloatScalar | ScalarFloatArray, maxx: FloatScalar | ScalarFloatArray, maxy: FloatScalar | ScalarFloatArray, *, crs: CrsInput, ccw: bool = True, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Polygon | MultiPolygon
box(minx: FloatScalar | ScalarFloatArray, miny: FloatScalar | ScalarFloatArray, maxx: FloatScalar | ScalarFloatArray, maxy: FloatScalar | ScalarFloatArray, *, crs: CrsInput | None, ccw: bool = True, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> Polygon | MultiPolygon
Create a rectangular polygon from bounds (minx, miny, maxx, maxy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
minx
|
float
|
Finite rectangle bounds. With a geographic CRS, |
required |
miny
|
float
|
Finite rectangle bounds. With a geographic CRS, |
required |
maxx
|
float
|
Finite rectangle bounds. With a geographic CRS, |
required |
maxy
|
float
|
Finite rectangle bounds. With a geographic CRS, |
required |
crs
|
CRS - like
|
CRS label (EPSG code, authority string, or WKT); attached as metadata,
coordinates are not transformed.
With a geographic CRS, bounds within the frame's native longitude and
latitude ranges use chart edges along parallels and meridians. A
seam-crossing interval returns a |
required |
ccw
|
bool
|
If |
True
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
Polygon | MultiPolygon
|
A rectangular polygon, or a MultiPolygon for a seam-crossing interval. |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If a bound is non-finite or south exceeds north. |
CRSError
|
If |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> gm.box(0, 0, 2, 1).to_wkt()
'POLYGON ((0 0, 2 0, 2 1, 0 1, 0 0))'
>>> gm.box(0, 0, 2, 1, ccw=False).to_wkt()
'POLYGON ((0 0, 0 1, 2 1, 2 0, 0 0))'
>>> gm.box(170, -10, -170, 10, crs=4326).bounds
(170.0, -10.0, -170.0, 10.0)
boxes
¶
Accepted call forms
boxes(minx: FloatInput, miny: FloatInput, maxx: FloatInput, maxy: FloatInput, *, crs: None = None, ccw: bool = True, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[Polygon]
boxes(minx: FloatInput, miny: FloatInput, maxx: FloatInput, maxy: FloatInput, *, crs: CrsInput, ccw: bool = True, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[Polygon | MultiPolygon]
boxes(minx: FloatInput, miny: FloatInput, maxx: FloatInput, maxy: FloatInput, *, crs: CrsInput | None, ccw: bool = True, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[Polygon | MultiPolygon]
Create a GeometryArray of rectangular polygons from bound columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
minx
|
float or sequence of float
|
Rectangle bounds per row. Scalars broadcast numpy-style; four scalar bounds produce a one-row array. |
required |
miny
|
float or sequence of float
|
Rectangle bounds per row. Scalars broadcast numpy-style; four scalar bounds produce a one-row array. |
required |
maxx
|
float or sequence of float
|
Rectangle bounds per row. Scalars broadcast numpy-style; four scalar bounds produce a one-row array. |
required |
maxy
|
float or sequence of float
|
Rectangle bounds per row. Scalars broadcast numpy-style; four scalar bounds produce a one-row array. |
required |
crs
|
CRS - like
|
CRS applied to every box. Geographic rows follow the same native-range
chart-edge and corner-only unwrapped rules as |
required |
ccw
|
bool
|
If |
True
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If a bound is non-finite or south exceeds north in any row. |
CRSError
|
If |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> gm.boxes(0, 0, [1, 2], [1, 2]).to_wkt()
['POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))', 'POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))']
>>> gm.boxes([170], [-10], [-170], [10], crs=4326)[0].bounds
(170.0, -10.0, -170.0, 10.0)
points
¶
Accepted call forms
points(x: Iterable[Iterable[float]] | Coordinates | Iterable[Point], y: None = None, *, z: FloatInput | None = None, m: FloatInput | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[Point]
points(x: FloatInput, y: FloatInput, *, z: FloatInput | None = None, m: FloatInput | None = None, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[Point]
Create a GeometryArray of points from parallel coordinate columns.
Pass either coordinate rows or separate x/y columns. Separate
columns keep axis order explicit and accept scalars that broadcast across
rows; when both are scalars, the result contains one point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
coordinate rows or float or sequence of float
|
Coordinate rows as |
required |
y
|
float or sequence of float
|
Y column when |
required |
z
|
float or sequence of float
|
Z and M ordinates, broadcast like |
None
|
m
|
float or sequence of float
|
Z and M ordinates, broadcast like |
None
|
crs
|
CRS - like
|
CRS label (EPSG code, authority string, or WKT); attached as metadata, coordinates are not transformed. |
None
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One Point per coordinate. |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If columns differ in length or are non-finite. |
CRSError
|
If |
GeometryError
|
If |
See Also
Point : Build a single point.
Examples:
>>> import gometry as gm
>>> gm.points([0, 1], [0, 1]).to_wkt()
['POINT (0 0)', 'POINT (1 1)']
>>> gm.points(1, 2).to_wkt()
['POINT (1 2)']
>>> gm.points([(1, 2), (3, 4)]).to_wkt()
['POINT (1 2)', 'POINT (3 4)']
line_strings
¶
line_strings(values: Iterable[LineString | (Iterable[Iterable[float]] | Coordinates)], *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[LineString]
Create a GeometryArray of linestrings from coordinate rows or Linestrings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
sequence
|
Each member is a |
required |
crs
|
CRS - like
|
CRS applied to every linestring. |
None
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If a member line has fewer than two vertices or non-finite coordinates. |
TypeError
|
If a geometry row is not a |
CRSError
|
If |
CRSMismatchError
|
If geometry rows do not share a CRS or coordinate epoch. |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> lines = gm.line_strings([[(0, 0), (1, 1)], [(2, 2), (3, 3)]])
>>> len(lines)
2
polygons
¶
polygons(values: Iterable[Polygon | (Iterable[Iterable[float]] | Coordinates) | Iterable[Iterable[Iterable[float]] | Coordinates]], *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[Polygon]
Create a GeometryArray of polygons from raw coordinates or Polygons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
sequence
|
Each member is a |
required |
crs
|
CRS - like
|
CRS applied to every polygon. |
None
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If a ring has fewer than three corners or non-finite coordinates. |
TypeError
|
If a geometry row is not a |
CRSError
|
If |
CRSMismatchError
|
If geometry rows do not share a CRS or coordinate epoch. |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> polys = gm.polygons([[(0, 0), (1, 0), (1, 1), (0, 1)]])
>>> len(polys)
1
multi_points
¶
multi_points(values: Iterable[MultiPoint | Iterable[Point | Iterable[float]] | (Iterable[Iterable[float]] | Coordinates)], *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[MultiPoint]
Create a GeometryArray of multipoints from per-row inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
sequence
|
Each member is a |
required |
crs
|
CRS - like
|
CRS applied to every multipoint. |
None
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If any coordinate is non-finite or has mixed dimensionality. |
TypeError
|
If a geometry row is not a |
CRSError
|
If |
CRSMismatchError
|
If geometry rows or multipart members do not share a CRS or epoch. |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> gm.multi_points([[(0, 0), (1, 1)]]).to_wkt()
['MULTIPOINT ((0 0), (1 1))']
multi_line_strings
¶
multi_line_strings(values: Iterable[MultiLineString | Iterable[LineString | (Iterable[Iterable[float]] | Coordinates)]], *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[MultiLineString]
Create a GeometryArray of multilinestrings from per-row inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
sequence
|
Each member is a |
required |
crs
|
CRS - like
|
CRS applied to every multilinestring. |
None
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If a member line has fewer than two vertices or non-finite coordinates. |
TypeError
|
If a geometry row is not a |
CRSError
|
If |
CRSMismatchError
|
If geometry rows or multipart members do not share a CRS or epoch. |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> gm.multi_line_strings([[[(0, 0), (1, 1)]]]).to_wkt()
['MULTILINESTRING ((0 0, 1 1))']
multi_polygons
¶
multi_polygons(values: Iterable[MultiPolygon | Iterable[Polygon | (Iterable[Iterable[float]] | Coordinates) | Iterable[Iterable[Iterable[float]] | Coordinates]]], *, crs: CrsInput | None = None, epoch: SupportsFloat | SupportsIndex | FloatScalar | ScalarFloatArray | None = None) -> GeometryArray[MultiPolygon]
Create a GeometryArray of multipolygons from per-row inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
sequence
|
Each member is a |
required |
crs
|
CRS - like
|
CRS applied to every multipolygon. |
None
|
epoch
|
numeric scalar or 0-D numeric array
|
Coordinate epoch (decimal year) for time-dependent frames. |
None
|
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If any ring has fewer than three corners or non-finite coordinates. |
TypeError
|
If a geometry row is not a |
CRSError
|
If |
CRSMismatchError
|
If geometry rows or multipart members do not share a CRS or epoch. |
GeometryError
|
If |
Examples:
>>> import gometry as gm
>>> gm.multi_polygons([[[[(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]]]]).to_wkt()
['MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)))']