obspy.core.inventory.inventory.Inventory.write

Inventory.write(path_or_file_object, format, **kwargs)[source]

Writes the inventory object to a file or file-like object in the specified format.

Parameters:
  • path_or_file_object – File name or file-like object to be written to.

  • format (str) – The file format to use (e.g. "STATIONXML"). See the Supported Formats section below for a list of supported formats.

  • kwargs – Additional keyword arguments passed to the underlying plugin’s writer method.

Example

>>> from obspy import read_inventory
>>> inventory = read_inventory()
>>> inventory.write("example.xml",
...                 format="STATIONXML")  

Supported Formats

Additional ObsPy modules extend the parameters of the write() method. The following table summarizes all known formats with write capability currently available for ObsPy.

Please refer to the Linked Function Call of each module for any extra options available.

Format

Used Module

Linked Function Call

CSS

obspy.io.css

obspy.io.css.station._write_css()

KML

obspy.io.kml

obspy.io.kml.core._write_kml()

SACPZ

obspy.io.sac

obspy.io.sac.sacpz._write_sacpz()

SHAPEFILE

obspy.io.shapefile

obspy.io.shapefile.core._write_shapefile()

STATIONTXT

obspy.io.stationtxt

obspy.io.stationtxt.core._write_stationtxt()

STATIONXML

obspy.io.stationxml

obspy.io.stationxml.core._write_stationxml()