Reads and writes feature collections from/to various feature collection file formats.
The following default file formats are currently supported by GPlates:
|File Format||Filename Extension||Supports Read||Supports Write|
|GPlates Markup Language||‘.gpml’||Yes||Yes|
|Compressed GPML||‘.gpmlz’ or ‘.gpml.gz’||Yes||Yes|
|PLATES4 line||‘.dat’ or ‘.pla’||Yes||Yes|
|GMAP Virtual Geomagnetic Poles||‘.vgp’||Yes||No|
In the future, support will be added to enable users to implement and register readers/writers for other file formats (or their own non-standard file formats).
Create a new registry of feature collection readers/writers and registers the default file formats supported by GPlates.
feature_collection_file_format_registry = pygplates.FeatureCollectionFileFormatRegistry()
|__init__()||Create a new registry of feature collection readers/writers and registers the default file formats supported by GPlates.|
|read(filename)||Reads one or more feature collections (from one or more files).|
|write(feature_collection, filename)||Writes a feature collection to the file with name filename.|
Reads one or more feature collections (from one or more files).
|Parameters:||filename (string, or sequence of strings) – the name of the file (or files) to read|
|Return type:||FeatureCollection, list of FeatureCollection|
|Raises:||OpenFileForReadingError if any file is not readable|
|Raises:||FileFormatNotSupportedError if any file format (identified by a filename extension) does not support reading|
try: feature_collection = feature_collection_file_format_registry.read(filename) except pygplates.OpenFileForReadingError: # Handle inability to read from file. ... except pygplates.FileFormatNotSupportedError: # Handle unsupported file format (for reading). ...
The returned feature collection may contain fewer features than are stored in the file if there were read errors. TODO: return read errors.
Writes a feature collection to the file with name filename.
OpenFileForWritingError if the file is not writable
FileFormatNotSupportedError if the file format (identified by the filename extension) does not support writing
try: feature_collection_file_format_registry.write(feature_collection, filename) except pygplates.OpenFileForWritingError: # Handle inability to write to file. ... except pygplates.FileFormatNotSupportedError: # Handle unsupported file format (for writing). ...