geopandas.GeoSeries.to_file

GeoSeries.to_file(filename, driver=None, index=None, **kwargs)

Write the GeoSeries to a file.

By default, an ESRI shapefile is written, but any OGR data source supported by Fiona can be written.

Parameters
filenamestring

File path or file handle to write to.

driverstring, default None

The OGR format driver used to write the vector file. If not specified, it attempts to infer it from the file extension. If no extension is specified, it saves ESRI Shapefile to a folder.

indexbool, 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.

New in version 0.7: Previously the index was not written.

See also

GeoDataFrame.to_file

write GeoDataFrame to file

read_file

read file to GeoDataFame

Notes

The extra keyword arguments **kwargs are passed to fiona.open and can be used to write to multi-layer data, store data within archives (zip files), etc.

Examples

>>> s.to_file('series.shp')  
>>> s.to_file('series.gpkg', driver='GPKG', layer='name1')  
>>> s.to_file('series.geojson', driver='GeoJSON')