> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GeoSeries.to_arrow

> Encode a GeoSeries to GeoArrow format.

Encode a GeoSeries to GeoArrow format.

See [https://geoarrow.org/](https://geoarrow.org/) for details on the GeoArrow specification.

This functions returns a generic Arrow array object implementing
the `Arrow PyCapsule Protocol`\_ (i.e. having an `__arrow_c_array__`
method). This object can then be consumed by your Arrow implementation
of choice that supports this protocol.

.. \_Arrow PyCapsule Protocol: [https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html](https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html)

Note: Requires geopandas versions >= 1.0.0 to use with Sedona.

## Signature

```python theme={"system"}
to_arrow(geometry_encoding='WKB', interleaved=True, include_z=None)
```

## Parameters

<ParamField path="geometry_encoding" type="(WKB, geoarrow)" default="'WKB'">
  The GeoArrow encoding to use for the data conversion.
</ParamField>

<ParamField path="interleaved" type="bool" default="True">
  Only relevant for 'geoarrow' encoding. If True, the geometries'
  coordinates are interleaved in a single fixed size list array.
  If False, the coordinates are stored as separate arrays in a
  struct type.
</ParamField>

<ParamField path="include_z" type="bool" default="None">
  Only relevant for 'geoarrow' encoding (for WKB, the dimensionality
  of the individual geometries is preserved).
  If False, return 2D geometries. If True, include the third dimension
  in the output (if a geometry has no third dimension, the z-coordinates
  will be NaN). By default, will infer the dimensionality from the
  input geometries. Note that this inference can be unreliable with
  empty geometries (for a guaranteed result, it is recommended to
  specify the keyword).
</ParamField>

## Returns

<ResponseField name="return" type="GeoArrowArray">
  A generic Arrow array object with geometry data encoded to GeoArrow.
</ResponseField>

## Examples

```python theme={"system"}
>>> from sedona.spark.geopandas import GeoSeries
>>> from shapely.geometry import Point
>>> gser = GeoSeries([Point(1, 2), Point(2, 1)])
>>> gser
0    POINT (1 2)
1    POINT (2 1)
dtype: geometry
```

```python theme={"system"}
>>> arrow_array = gser.to_arrow()
>>> arrow_array
<geopandas.io._geoarrow.GeoArrowArray object at ...>
```

The returned array object needs to be consumed by a library implementing
the Arrow PyCapsule Protocol. For example, wrapping the data as a
pyarrow\.Array (requires pyarrow >= 14.0):

```python theme={"system"}
>>> import pyarrow as pa
>>> array = pa.array(arrow_array)
>>> array
<pyarrow.lib.BinaryArray object at ...>
[
  0101000000000000000000F03F0000000000000040,
  01010000000000000000000040000000000000F03F
]
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.