- GeoSeries.to_file(filename, driver=None, index=None, **kwargs)#
GeoSeriesto a file.
By default, an ESRI shapefile is written, but any OGR data source supported by Fiona can be written.
File path or file handle to write to. The path may specify a GDAL VSI scheme.
- 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.
- modestring, default ‘w’
The write mode, ‘w’ to overwrite the existing file and ‘a’ to append. Not all drivers support appending. The drivers that support appending are listed in fiona.supported_drivers or Toblerity/Fiona
- crspyproj.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 crs df attribute. The value can be anything accepted by
pyproj.CRS.from_user_input(), such as an authority string (eg “EPSG:4326”) or a WKT string.
- enginestr, “fiona” or “pyogrio”
The underlying library that is used to write the file. Currently, the supported options are “fiona” and “pyogrio”. Defaults to “fiona” if installed, otherwise tries “pyogrio”.
Keyword args to be passed to the engine, and can be used to write to multi-layer data, store data within archives (zip files), etc. In case of the “fiona” engine, the keyword arguments are passed to fiona.open`. For more information on possible keywords, type:
import fiona; help(fiona.open). In case of the “pyogrio” engine, the keyword arguments are passed to pyogrio.write_dataframe.
>>> s.to_file('series.gpkg', driver='GPKG', layer='name1')
>>> s.to_file('series.geojson', driver='GeoJSON')