> ## 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.

# GeoArrow

> Move data between Spark DataFrames and GeoPandas or GeoArrow with Apache Arrow.

```python theme={"system"}
from sedona.spark import create_spatial_dataframe, dataframe_to_arrow
```

## create\_spatial\_dataframe

```python theme={"system"}
create_spatial_dataframe(spark: SparkSession, gdf: gpd.GeoDataFrame) -> DataFrame
```

Create a Spark DataFrame from a GeoPandas GeoDataFrame, transferring the data with Arrow.

This is faster than `spark.createDataFrame(gdf)` for large GeoDataFrames.
Geometry columns become Sedona geometry columns, and the other columns get the
Spark types of their Arrow types.

#### Parameters

<ParamField path="spark" type="SparkSession" required>
  The Spark session.
</ParamField>

<ParamField path="gdf" type="gpd.GeoDataFrame" required>
  The GeoPandas GeoDataFrame to convert. It must have at least one
  geometry column.
</ParamField>

#### Returns

<ResponseField name="return" type="DataFrame">
  A Spark DataFrame with the columns of `gdf`.
</ResponseField>

#### Raises

* `ValueError`: If `gdf` has no geometry column.

## dataframe\_to\_arrow

```python theme={"system"}
dataframe_to_arrow(df, crs=None)
```

Collect a DataFrame as a PyArrow Table

In the output Table, geometry will be encoded as a GeoArrow extension type.
The resulting output is compatible with `lonboard.viz()`,
`geopandas.GeoDataFrame.from_arrow()`, or any library compatible with
GeoArrow extension types.

#### Parameters

<ParamField path="df" required>
  A Spark DataFrame
</ParamField>

<ParamField path="crs" default="None">
  A CRS-like object (e.g., `pyproj.CRS` or string interpretable by
  `pyproj.CRS`). If provided, this will override any CRS present in the output
  geometries. If omitted, the CRS will be inferred from the values present in
  the output if exactly one CRS is present in the output.
</ParamField>

#### Returns

<ResponseField name="return">
  A `pyarrow.Table`.
</ResponseField>


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