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

# GeoDataFrame.to_file

> Write the GeoDataFrame to a file.

Write the `GeoDataFrame` to a file.

## Signature

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

## Parameters

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

<ParamField path="driver" type="str | None" default="None">
  The format driver used to write the file.
  If not specified, it attempts to infer it from the file extension.
  If no extension is specified, Sedona will error.

  Options: "geojson", "geopackage", "geoparquet"
</ParamField>

<ParamField path="schema" type="dict | None" default="None">
  Not applicable to Sedona's implementation.
</ParamField>

<ParamField path="index" type="bool | None" default="None">
  If True, write index into one or more columns (for MultiIndex).
  Default None writes the index into one or more columns only if
  the index is named, is a MultiIndex, or has a non-integer data
  type. If False, no index is written.
</ParamField>

<ParamField path="kwargs">
  Additional keyword arguments:

  mode : str, default 'w'
  The write mode, 'w' to overwrite the existing file and 'a' to append.
  'overwrite' and 'append' are equivalent to 'w' and 'a' respectively.

  crs : pyproj.CRS, default None
  If specified, the CRS is passed to Fiona to better control how the file is written.
  If None, GeoPandas will determine the CRS based on the `crs` attribute.
  The value can be anything accepted by
  `pyproj.CRS.from_user_input <pyproj.crs.CRS.from_user_input>`,
  such as an authority string (e.g., "EPSG:4326") or a WKT string.

  engine : str
  Not applicable to Sedona's implementation.

  metadata : dict\[str, str], default None
  Optional metadata to be stored in the file. Keys and values must be
  strings. Supported only for "GPKG" driver. Not supported by Sedona.
</ParamField>

## Examples

```python theme={"system"}
>>> from shapely.geometry import Point, LineString
>>> from sedona.spark.geopandas import GeoDataFrame
```

```python theme={"system"}
>>> gdf = GeoDataFrame({
...     "geometry": [Point(0, 0), LineString([(0, 0), (1, 1)])],
...     "int": [1, 2]
... })
>>> gdf.to_file("output.parquet", driver="geoparquet")
```

With selected drivers you can also append to a file with `mode="a"`:

```python theme={"system"}
>>> gdf.to_file("output.geojson", driver="geojson", mode="a")
```

When the index is of non-integer dtype, `index=None` (default) is treated as True,
writing the index to the file.

```python theme={"system"}
>>> gdf = GeoDataFrame({"geometry": [Point(0, 0), Point(1, 1)]}, index=["a", "b"])
>>> gdf.to_file("output_with_index.parquet", driver="geoparquet")
```


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