Source: https://gometry.monicz.dev/api/io/

# I/O & interop

Parse external representations and exchange Arrow or text/binary geometry data.

**Related:** [Text & binary formats](https://gometry.monicz.dev/ecosystem/text-formats/)

## from\_arrow

Accepted call forms

```python
from_arrow(
    data: Array | ChunkedArray,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    interior: Literal['left', 'smaller'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_arrow(
    data: Table | RecordBatch | RecordBatchReader,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    interior: Literal['left', 'smaller'] | None = None,
) -> Features
```

```python
from_arrow(
    data: object,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    interior: Literal['left', 'smaller'] | None = None,
) -> GeometryArray[Geometry | None] | Features
```

```python
from_arrow(
    data: Array | ChunkedArray,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    interior: Literal['left', 'smaller'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_arrow(
    data: Table | RecordBatch | RecordBatchReader,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    interior: Literal['left', 'smaller'] | None = None,
) -> Features
```

```python
from_arrow(
    data: object,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    interior: Literal['left', 'smaller'] | None = None,
) -> GeometryArray[Geometry | None] | Features
```

Import a geometry array or a geometry-bearing Arrow feature table.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `data` | `Arrow array, table, record batch or stream` | GeoArrow or WKB geometry data, or a table with a geometry column and aligned attributes. Arrow C data and stream providers are accepted. | *required* |
| `geometry` | `str or None` | Geometry column name for a table. When omitted, a declared primary geometry or an unambiguous geometry column is selected. | `None` |
| `id_column` | `(str, Ellipsis or None)` | Feature ID column. The default uses recorded ID metadata when present; `None` treats all non-geometry columns as properties. | `...` |
| `crs` | `CrsInput or None` | Coordinate reference system to apply to the imported geometry. | `None` |
| `srids` | `mapping[int, CrsInput] or None` | Resolve nonzero identifiers in GeoArrow WKB storage through this source namespace. A supplied mapping disables EPSG fallback. | `None` |
| `epoch` | `float or None` | Coordinate epoch to apply to the imported geometry. | `None` |
| `model` | `('planar', 'chart', 'spherical')` | Edge model for plain WKB storage without GeoArrow edge metadata. GeoArrow extensions declare planar edges when `edges` is omitted. | `"planar"` |
| `space` | `Space or None` | Complete interpretation to assert or apply. Cannot be combined with non-`None` `crs`, `epoch`, or `model` values. | `None` |
| `interior` | `('left', 'smaller')` | Select the directed left-side or smaller region for geographic rings. Omission uses directed left-side admission. | `"left"` |

Returns:

| Type | Description |
| --- | --- |
| `GeometryArray or Features` | Arrays become geometry arrays; tables and record-batch streams become immutable feature collections. |

Raises:

| Type | Description |
| --- | --- |
| `CRSError` | If coordinate reference system or epoch metadata is invalid. |
| `GeometryError` | If geometry data violates a geometry invariant, or `interior` is invalid or selects a region for Planar geometry. |
| `ParseError` | If Arrow buffers, geometry metadata, or encoded geometry are malformed. |
| `TypeError` | If the input or its schema is unsupported. |
| `OSError` | If an Arrow stream callback fails. |
| `MemoryError` | If an Arrow stream callback reports allocation failure. |

## from\_arrow\_batches

Accepted call forms

```python
from_arrow_batches(
    reader: SupportsArrowStream | RecordBatchReader,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    interior: Literal['left', 'smaller'] | None = None,
) -> Generator[Features, None, None]
```

```python
from_arrow_batches(
    reader: SupportsArrowStream | RecordBatchReader,
    *,
    geometry: str | None = None,
    id_column: str | EllipsisType | None = ...,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    interior: Literal['left', 'smaller'] | None = None,
) -> Generator[Features, None, None]
```

Yield feature snapshots from a caller-owned Arrow record-batch stream.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `reader` | `Arrow record-batch reader or stream` | The caller-owned reader or Arrow C stream provider. | *required* |
| `geometry` | `str or None` | Geometry column name, or `None` to select from metadata or an unambiguous geometry column. | `None` |
| `id_column` | `(str, Ellipsis or None)` | Feature ID column. The default uses recorded ID metadata when present; `None` treats non-geometry columns as properties. | `...` |
| `crs` | `CrsInput or None` | CRS to attach when the stream schema omits it. | `None` |
| `srids` | `mapping[int, CrsInput] or None` | Source-local WKB SRID mapping, passed to each batch's shared frame admission. | `None` |
| `epoch` | `float or None` | Coordinate epoch to attach when stream metadata omits it. | `None` |
| `model` | `('planar', 'chart', 'spherical')` | Edge model for plain WKB batches without GeoArrow edge metadata. GeoArrow extensions declare planar edges when `edges` is omitted. | `"planar"` |
| `space` | `Space or None` | Complete interpretation to assert or apply. Cannot be combined with non-`None` `crs`, `epoch`, or `model` values. | `None` |
| `interior` | `('left', 'smaller')` | Select the directed left-side or smaller region for geographic rings. Omission uses directed left-side admission. | `"left"` |

Returns:

| Type | Description |
| --- | --- |
| `generator of Features` | Immutable snapshots in stream order. Close the generator when stopping early to release its stream resources. The complete Space is resolved from schema metadata, explicit hints, or the first batch's present geometry records before that batch is yielded. That Space then governs the stream. An empty or all-missing first batch without a declared CRS commits an unreferenced Space; declare a CRS upfront if a later batch may contain only EWKB SRIDs. A conflicting later batch fails before it is yielded, and earlier snapshots remain usable. |

Raises:

| Type | Description |
| --- | --- |
| `TypeError` | If `reader` does not supply a record-batch stream, or `space` is combined with a non-None `crs`, `epoch`, or `model`. |
| `CRSError` | If the stream's coordinate reference system cannot be resolved or a batch conflicts with the retained reference frame. |
| `GeometryError` | If a batch cannot be interpreted in the stream's Space or `interior` is neither `None` nor a supported ring-selection name. |

## from\_geojson

Accepted call forms

```python
from_geojson(
    data: str
    | bytes
    | bytearray
    | memoryview
    | Mapping[str, Any]
    | SupportsGeoInterface
    | (PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray)
    | Iterable[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ],
    *,
    as_features: Literal[True],
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Features
```

```python
from_geojson(
    data: GeoJsonGeometry | SupportsGeoInterface[GeoJsonGeometry],
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Geometry
```

```python
from_geojson(
    data: GeoJsonFeature
    | GeoJsonFeatureNonNull
    | SupportsGeoInterface[GeoJsonFeature]
    | SupportsGeoInterface[GeoJsonFeatureNonNull],
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Feature
```

```python
from_geojson(
    data: GeoJsonFeatureCollection
    | SupportsGeoInterface[GeoJsonFeatureCollection],
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Features
```

```python
from_geojson(
    data: str | bytes | bytearray | memoryview,
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Geometry | GeometryArray[Geometry | None] | Feature | Features
```

```python
from_geojson(
    data: str
    | bytes
    | bytearray
    | memoryview
    | Mapping[str, Any]
    | SupportsGeoInterface
    | (PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray)
    | Iterable[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ],
    *,
    as_features: Literal[True],
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Features
```

```python
from_geojson(
    data: GeoJsonGeometry | SupportsGeoInterface[GeoJsonGeometry],
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Geometry
```

```python
from_geojson(
    data: GeoJsonFeature
    | GeoJsonFeatureNonNull
    | SupportsGeoInterface[GeoJsonFeature]
    | SupportsGeoInterface[GeoJsonFeatureNonNull],
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Feature
```

```python
from_geojson(
    data: GeoJsonFeatureCollection
    | SupportsGeoInterface[GeoJsonFeatureCollection],
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Features
```

```python
from_geojson(
    data: str | bytes | bytearray | memoryview,
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Geometry | GeometryArray[Geometry | None] | Feature | Features
```

```python
from_geojson(
    data: PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray,
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> GeometryArray[Geometry | None] | Features
```

```python
from_geojson(
    data: Iterable[
        GeoJsonGeometry | SupportsGeoInterface[GeoJsonGeometry] | None
    ],
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> GeometryArray[Geometry | None]
```

```python
from_geojson(
    data: Sequence[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ]
    | Iterator[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ]
    | Iterable[Mapping[str, Any] | SupportsGeoInterface | None],
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> GeometryArray[Geometry | None] | Features
```

```python
from_geojson(
    data: str
    | bytes
    | bytearray
    | memoryview
    | Mapping[str, Any]
    | SupportsGeoInterface
    | (PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray)
    | Iterable[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ],
    *,
    as_features: Literal[False] = False,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Geometry | GeometryArray[Geometry | None] | Feature | Features
```

```python
from_geojson(
    data: str
    | bytes
    | bytearray
    | memoryview
    | Mapping[str, Any]
    | SupportsGeoInterface
    | (PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray)
    | Iterable[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ],
    *,
    as_features: bool,
    crs: None = ...,
    epoch: None = None,
    space: Space,
) -> Geometry | GeometryArray[Geometry | None] | Feature | Features
```

```python
from_geojson(
    data: PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray,
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> GeometryArray[Geometry | None] | Features
```

```python
from_geojson(
    data: Iterable[
        GeoJsonGeometry | SupportsGeoInterface[GeoJsonGeometry] | None
    ],
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_geojson(
    data: Sequence[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ]
    | Iterator[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ]
    | Iterable[Mapping[str, Any] | SupportsGeoInterface | None],
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> GeometryArray[Geometry | None] | Features
```

```python
from_geojson(
    data: str
    | bytes
    | bytearray
    | memoryview
    | Mapping[str, Any]
    | SupportsGeoInterface
    | (PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray)
    | Iterable[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ],
    *,
    as_features: Literal[False] = False,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Geometry | GeometryArray[Geometry | None] | Feature | Features
```

```python
from_geojson(
    data: str
    | bytes
    | bytearray
    | memoryview
    | Mapping[str, Any]
    | SupportsGeoInterface
    | (PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray)
    | Iterable[
        str
        | bytes
        | bytearray
        | memoryview
        | Mapping[str, Any]
        | SupportsGeoInterface
        | None
    ],
    *,
    as_features: bool,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    space: None = None,
) -> Geometry | GeometryArray[Geometry | None] | Feature | Features
```

Parse GeoJSON geometry, rows, or feature metadata.

Geometry, Feature and FeatureCollection documents decode to `Geometry`,
`Feature` and `Features` respectively. A mixed row batch becomes
`Features`; a geometry-only batch becomes `GeometryArray`.

Coordinate sequences are **axis-uniform**: every position in one sequence
(LineString, MultiPoint member list, ring, …) must share the same axes
(all XY or all XYZ). RFC 7946 makes the third ordinate optional per
position, but gometry's coordinate model requires finite values on every
active ordinate and rejects non-finite coordinates, so mixed XY/XYZ within
one sequence is a `ParseError` rather than a silent 0-elevation fill.
Distinct members of a `GeometryCollection` may still differ in axes.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `data` | `str, mapping, row iterable, or dataframe/Arrow column` | A GeoJSON string, mapping, row iterable, or pandas/Polars Series or PyArrow Array/ChunkedArray. Feature and FeatureCollection inputs are accepted. Missing column values become missing rows. | *required* |
| `as_features` | `bool` | When true, normalize any supported input to `Features`, including geometry-only and empty batches. Missing rows retain null properties and no ID. When omitted, this is false. | *required* |
| `crs` | `CRS - like or None` | CRS to attach. GeoJSON coordinates are WGS 84 by specification, so the default declares OGC:CRS84 (lon/lat, matching GeoParquet); pass `None` for a CRS-free geometry or `crs=4326` for EPSG:4326. Only the WGS84 family (`EPSG:4326`, `EPSG:4979`, `OGC:CRS84`, `OGC:CRS84h`) is accepted — reproject first for other CRS. A legacy top-level `crs` member (pre-RFC 7946) is ignored when it agrees with `crs=` and raises on conflict or unsupported declarations. | `...` |
| `epoch` | `numeric scalar or 0-D numeric array` | Coordinate epoch (decimal year) to attach as frame metadata. | `None` |
| `space` | `Space` | Complete Planar interpretation for the GeoJSON coordinates. It cannot be combined with non-None `crs` or `epoch` values. | `None` |

Returns:

| Type | Description |
| --- | --- |
| `(Geometry, GeometryArray, Feature or Features)` | The decoded value, preserving the semantic shape of the input. |

Raises:

| Type | Description |
| --- | --- |
| `ParseError` | If the GeoJSON is malformed or an unsupported type, a coordinate sequence mixes axes (XY with XYZ), a coordinate integer is not exactly representable as binary64, a `bbox`, Feature `properties` or `id` is malformed, a Python mapping contains non-JSON data, or a legacy `crs` member is unsupported or conflicts with `crs`, a position is outside the WGS84 domain, or a ring fails structural admission (`format` is `"geojson"`). |
| `CRSError` | If `crs` is not a recognized CRS or is outside the WGS84 family, or `epoch` is set with `crs=None`. |
| `TypeError` | If `space` is non-Planar or is combined with non-None `crs` or `epoch` values. |
| `GeometryError` | If `epoch` is not a finite decimal year. |

Notes

Finite decimals parse as correctly-rounded binary64 (bit-exact round-trip
with `to_geojson`). Integer tokens and Python `int` values are admitted
only when exactly representable as `float`; non-exact integers raise
rather than silently rounding. Text and mapping inputs share this rule.
Dataframe and Arrow columns are converted to their native Python row values
before the same decoder runs.


See Also

[Geometry.to\_geojson](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.to_geojson "to_geojson") : Serialize a geometry to GeoJSON.
[Features](https://gometry.monicz.dev/api/features/#gometry.Features "Features") : Immutable, aligned geometry, property and ID columns.

Examples:

```pycon
>>> import gometry as gm
>>> geometry = gm.from_geojson('{"type": "Point", "coordinates": [1, 2]}')
>>> assert isinstance(geometry, gm.Geometry)
>>> geometry.to_wkt()
'POINT (1 2)'
```

## from\_polyline

Accepted call forms

```python
from_polyline(
    data: str,
    *,
    precision: int = 5,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
) -> Point | LineString
```

```python
from_polyline(
    data: PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray,
    *,
    precision: int = 5,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
) -> GeometryArray[Point | LineString | None]
```

```python
from_polyline(
    data: Iterable[str],
    *,
    precision: int = 5,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
) -> GeometryArray[Point | LineString]
```

```python
from_polyline(
    data: str,
    *,
    precision: int = 5,
    crs: None = ...,
    epoch: None = None,
    model: None = None,
    space: Space,
) -> Point | LineString
```

```python
from_polyline(
    data: PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray,
    *,
    precision: int = 5,
    crs: None = ...,
    epoch: None = None,
    model: None = None,
    space: Space,
) -> GeometryArray[Point | LineString | None]
```

```python
from_polyline(
    data: Iterable[str],
    *,
    precision: int = 5,
    crs: None = ...,
    epoch: None = None,
    model: None = None,
    space: Space,
) -> GeometryArray[Point | LineString]
```

```python
from_polyline(
    data: Iterable[str | None],
    *,
    precision: int = 5,
    crs: None = ...,
    epoch: None = None,
    model: None = None,
    space: Space,
) -> GeometryArray[Point | LineString | None]
```

```python
from_polyline(
    data: Iterable[str | None],
    *,
    precision: int = 5,
    crs: CrsInput | None = ...,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
) -> GeometryArray[Point | LineString | None]
```

Decode polyline text into `LineString`/`Point` geometries.

The Google Encoded Polyline Algorithm Format — the compact lat/lon
route encoding used by Google Maps, OSRM, and Valhalla. Accepts one
string (returns a `Point` for one coordinate, otherwise a `LineString`)
or an iterable/dataframe/Arrow column of strings/`None` rows (returns a
`GeometryArray` with missing rows). Polylines are WGS84 by definition, so results carry OGC:CRS84
unless `crs=None` explicitly requests a CRS-free result;
`epoch` restores coordinate-epoch metadata on round-trip.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `data` | `str, iterable of str, or dataframe/Arrow column` | Encoded polyline text or a pandas/Polars Series or PyArrow Array/ChunkedArray. Missing column values become missing rows. | *required* |
| `precision` | `int` | Decimal digits encoded per ordinate (`0` to `11`); 5 is the classic default, 6 the high-resolution variant. | `5` |
| `crs` | `CRS - like or None` | Space for the decoded longitude/latitude coordinates. Only WGS84 longitude/latitude CRS are valid. When neither `crs` nor `space` is supplied, use `OGC:CRS84`. Pass `crs=None` for CRS-free output. | `...` |
| `epoch` | `numeric scalar or 0-D numeric array` | Coordinate epoch (decimal year) to attach as frame metadata. | `None` |
| `model` | `('planar', 'chart', 'spherical')` | Curve model for the decoded coordinates. Omission uses Planar. | `"planar"` |
| `space` | `Space` | Complete WGS84 coordinate interpretation. It cannot be combined with separate `crs`, `epoch`, or `model` values. | `None` |

Returns:

| Type | Description |
| --- | --- |
| `Point, LineString, or GeometryArray` | A `Point` when the encoding has one coordinate, a `LineString` for two or more, or a `GeometryArray` for iterable input. |

Raises:

| Type | Description |
| --- | --- |
| `ParseError` | If the text is not valid polyline data. |
| `GeometryError` | If `precision` is out of range or the curve model is incompatible with the decoded coordinates. |
| `CRSError` | If `epoch` is set without `crs`, `crs` is not a WGS84-family CRS, or the selected Space cannot be constructed for the frame. |
| `TypeError` | If `space` is combined with non-None `crs`, `epoch`, or `model` values, or `model` is not supported. |

See Also

[Geometry.to\_polyline](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.to_polyline "to_polyline") : Encode a LineString or Point as a polyline.

Examples:

```pycon
>>> import gometry as gm
>>> gm.from_polyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@').to_wkt()
'LINESTRING (-120.2 38.5, -120.95 40.7, -126.453 43.252)'
```

## from\_wkb

Accepted call forms

```python
from_wkb(
    data: SupportsArrowArray
    | PandasSeries
    | PolarsSeries
    | PyArrowArray
    | PyArrowChunkedArray,
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkb(
    data: NDArray[uint8] | NDArray[int8],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry
```

```python
from_wkb(
    data: NDArray[object_],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkb(
    data: NDArray[bytes_],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry]
```

```python
from_wkb(
    data: Buffer,
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry
```

```python
from_wkb(
    data: Iterable[Buffer],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry]
```

```python
from_wkb(
    data: Iterable[Buffer | None],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkb(
    data: SupportsArrowArray
    | PandasSeries
    | PolarsSeries
    | PyArrowArray
    | PyArrowChunkedArray,
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkb(
    data: NDArray[uint8] | NDArray[int8],
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry
```

```python
from_wkb(
    data: NDArray[object_],
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkb(
    data: NDArray[bytes_],
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry]
```

```python
from_wkb(
    data: Buffer,
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry
```

```python
from_wkb(
    data: Iterable[Buffer],
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry]
```

```python
from_wkb(
    data: Iterable[Buffer | None],
    *,
    space: Space,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkb(
    data: Buffer | Iterable[Buffer | None],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry | GeometryArray[Geometry | None]
```

Parse a geometry (or array) from Well-Known Binary.

Also accepts EWKB; an embedded SRID becomes the geometry's CRS.
`SRID=0` / EWKB SRID 0 is PostGIS unknown → CRS-free. Nonzero codes
resolve through the canonical EPSG namespace unless `srids` supplies a
source-local mapping.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `data` | `bytes, byte buffer, iterable of buffers, or dataframe/Arrow column` | A WKB/EWKB byte buffer, an iterable of byte buffers, or a pandas/Polars Series or PyArrow Array/ChunkedArray of WKB values. A one-byte integer ndarray is one scalar byte buffer; other ndarrays are row columns. Missing column values become missing rows. | *required* |
| `crs` | `CRS - like` | CRS for SRID-less input. An embedded SRID that *contradicts* an explicit `crs` raises rather than silently winning. | `None` |
| `srids` | `mapping[int, CRS - like]` | Resolve embedded nonzero SRIDs in a source-local namespace instead of the default EPSG namespace. Missing identifiers fail rather than falling back to EPSG. Under `postgis_geography`, values describe the catalog CRS whose effective payload axes are derived as degrees. | `None` |
| `epoch` | `numeric scalar or 0-D numeric array` | Coordinate epoch (decimal year) to attach as frame metadata. | `None` |
| `model` | `('planar', 'chart', 'spherical')` | Curve model for the imported coordinates. Omission uses Planar unless `convention="postgis_geography"` selects Spherical. Explicit Chart or Spherical interpretation without a source convention assigns directed-left polygon interiors. | `"planar"` |
| `space` | `Space` | Complete interpretation for the imported coordinates. It cannot be combined with separate non-None `crs`, `epoch`, or `model` values. | `None` |
| `convention` | `('left', 'smaller', 'postgis_geography')` | Interpret coordinate-only polygon rings using directed-left selection, the smaller valid region, or PostGIS geography's polygon-owned exterior reference. `left` and `smaller` require an explicit geographic `model` or `space`. PostGIS geography supplies Spherical Space and degree-based payload axes; it does not transform coordinate values. | `"left"` |

Returns:

| Type | Description |
| --- | --- |
| `Geometry or GeometryArray` | A `GeometryArray` when `data` is an iterable, else a `Geometry`. |

Raises:

| Type | Description |
| --- | --- |
| `ParseError` | If the WKB is malformed. |
| `CRSMismatchError` | If an embedded SRID conflicts with `crs`. |
| `CRSError` | If a nonzero SRID is unresolved, `epoch` is set without `crs`, or PostGIS geography cannot derive an effective payload CRS. |
| `TypeError` | If `srids` is not a mapping from integer identifiers to CRS values, or `left`/`smaller` is requested without `model` or complete `space`. |
| `GeometryError` | If `epoch` is not a finite decimal year, `model` or `convention` is unsupported, the convention conflicts with the selected Space, or it cannot establish a representable region. |
| `InvalidGeometryError` | If `convention="smaller"` requires scoring an invalid ring region. |

Notes

The (E)WKB format does not carry a coordinate epoch and one does not
survive a WKB round-trip; `epoch=` attaches it as frame metadata (as
with `GeometryArray`), and Arrow interchange preserves it on export.


See Also

[Geometry.to\_wkb](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.to_wkb "to_wkb") : Serialize a geometry to WKB.

Examples:

```pycon
>>> import gometry as gm
>>> hex = '0101000000000000000000f03f0000000000000040'
>>> gm.from_wkb(bytes.fromhex(hex)).to_wkt()
'POINT (1 2)'
```

## from\_wkt

Accepted call forms

```python
from_wkt(
    data: str,
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry
```

```python
from_wkt(
    data: PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray,
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkt(
    data: Iterable[str],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry]
```

```python
from_wkt(
    data: str,
    *,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> Geometry
```

```python
from_wkt(
    data: PandasSeries | PolarsSeries | PyArrowArray | PyArrowChunkedArray,
    *,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkt(
    data: Iterable[str],
    *,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry]
```

```python
from_wkt(
    data: Iterable[str | None],
    *,
    crs: None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: None = None,
    model: None = None,
    space: Space,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

```python
from_wkt(
    data: Iterable[str | None],
    *,
    crs: CrsInput | None = None,
    srids: Mapping[int, CrsInput] | None = None,
    epoch: SupportsFloat
    | SupportsIndex
    | FloatScalar
    | ScalarFloatArray
    | None = None,
    model: Literal['planar', 'chart', 'spherical'] | None = None,
    space: None = None,
    convention: Literal['left', 'smaller', 'postgis_geography'] | None = None,
) -> GeometryArray[Geometry | None]
```

Parse a geometry (or array) from Well-Known Text.

Also accepts EWKT; an embedded `SRID=...;` prefix becomes the
geometry's CRS. `SRID=0` is PostGIS unknown/unspecified and yields a
CRS-free geometry. Nonzero codes resolve through the canonical EPSG
namespace unless `srids` supplies a source-local mapping.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `data` | `str, iterable of str, or dataframe/Arrow column` | A single WKT/EWKT string, an iterable of rows, or a pandas/Polars Series or PyArrow Array/ChunkedArray. Missing column values become missing rows. | *required* |
| `crs` | `CRS - like` | CRS for SRID-less input. An embedded SRID that *contradicts* an explicit `crs` raises rather than silently winning. | `None` |
| `srids` | `mapping[int, CRS - like]` | Resolve embedded nonzero SRIDs in a source-local namespace instead of the default EPSG namespace. Missing identifiers fail rather than falling back to EPSG. Under `postgis_geography`, values describe the catalog CRS whose effective payload axes are derived as degrees. | `None` |
| `epoch` | `numeric scalar or 0-D numeric array` | Coordinate epoch (decimal year) to attach as frame metadata. | `None` |
| `model` | `('planar', 'chart', 'spherical')` | Curve model for the imported coordinates. Omission uses Planar unless `convention="postgis_geography"` selects Spherical. Explicit Chart or Spherical interpretation without a source convention assigns directed-left polygon interiors. | `"planar"` |
| `space` | `Space` | Complete interpretation for the imported coordinates. It cannot be combined with separate non-None `crs`, `epoch`, or `model` values. | `None` |
| `convention` | `('left', 'smaller', 'postgis_geography')` | Interpret coordinate-only polygon rings using directed-left selection, the smaller valid region, or PostGIS geography's polygon-owned exterior reference. `left` and `smaller` require an explicit geographic `model` or `space`. PostGIS geography supplies Spherical Space and degree-based payload axes; it does not transform coordinate values. | `"left"` |

Returns:

| Type | Description |
| --- | --- |
| `Geometry or GeometryArray` | A `GeometryArray` when `data` is an iterable, else a `Geometry`. |

Raises:

| Type | Description |
| --- | --- |
| `ParseError` | If the WKT is malformed. |
| `CRSMismatchError` | If an embedded SRID conflicts with `crs`. |
| `CRSError` | If a nonzero SRID is unresolved, `epoch` is set without `crs`, or PostGIS geography cannot derive an effective payload CRS. |
| `TypeError` | If `srids` is not a mapping from integer identifiers to CRS values, or `left`/`smaller` is requested without `model` or complete `space`. |
| `GeometryError` | If `epoch` is not a finite decimal year, `model` or `convention` is unsupported, the convention conflicts with the selected Space, or it cannot establish a representable region. |
| `InvalidGeometryError` | If `convention="smaller"` requires scoring an invalid ring region. |

See Also

[Geometry.to\_wkt](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.to_wkt "to_wkt") : Serialize a geometry to WKT.

Examples:

```pycon
>>> import gometry as gm
>>> gm.from_wkt('POINT (1 2)').geometry_type
'Point'
>>> gm.from_wkt('SRID=4326;POINT (1 2)').crs
CRS("EPSG:4326")
```
