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

> Write the GeoSeries to a file.

Write the `GeoSeries` to a file.

## Signature

```python theme={"system"}
to_file(
    path: str,
    driver: Union[str, None] = None,
    schema: Union[dict, None] = None,
    index: Union[bool, None] = None,
    **kwargs,
)
```

## Parameters

<ParamField path="path" type="str" required>
  File path or file handle to write to.
</ParamField>

<ParamField path="driver" type="Union[str, None]" default="None">
  The format driver used to write the file, by default None. If not
  specified, it's inferred from the file extension. Available formats
  are "geojson", "geopackage", and "geoparquet".
</ParamField>

<ParamField path="schema" type="Union[dict, None]" default="None" />

<ParamField path="index" type="Union[bool, None]" default="None">
  If True, writes the index as a column. If False, no index is
  written. By default None, the index is written only if it is named,
  is a MultiIndex, or has a non-integer data type.
</ParamField>

<ParamField path="mode" type="str">
  The write mode: 'w' to overwrite the existing file or 'a' to append.
</ParamField>

<ParamField path="crs" type="pyproj.CRS">
  The coordinate reference system to write. If None, it is determined
  from the `GeoSeries` `crs` attribute. The value can be anything
  accepted by `pyproj.CRS.from_user_input()`, such as an
  authority string (e.g., "EPSG:4326") or a WKT string.
</ParamField>

<ParamField path="kwargs">
  Additional keyword arguments passed to the underlying writing engine.
</ParamField>

## Examples

```python theme={"system"}
>>> from shapely.geometry import Point, LineString
>>> from sedona.spark.geopandas import GeoSeries
>>> # Note: Examples write to temporary files for demonstration
>>> import tempfile
>>> import os
```

Create a GeoSeries:

```python theme={"system"}
>>> gs = GeoSeries(
...     [Point(0, 0), LineString([(1, 1), (2, 2)])],
...     index=["a", "b"]
... )
```

Save to a GeoParquet file:

```python theme={"system"}
>>> path_parquet = os.path.join(tempfile.gettempdir(), "data.parquet")
>>> gs.to_file(path_parquet, driver="geoparquet")
```

Append to a GeoJSON file:

```python theme={"system"}
>>> path_json = os.path.join(tempfile.gettempdir(), "data.json")
>>> gs.to_file(path_json, driver="geojson", mode='a')
```


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