Module gplately.gpml
This sub-module contains functions for manipulating GPML (.gpml
, .gpmlz
) files,
as well as pygplates.Feature
and pygplates.FeatureCollection
objects.
Functions
def create_feature_dict(features, id_type=pygplates.pygplates.FeatureId)
-
Create a dictionary mapping feature IDs to features.
Feature IDs can be either
str
orpygplates.FeatureId
, according toid_type
.Parameters
features
:valid argument for pygplates.FeaturesFunctionArgument
features
may be a singlepygplates.Feature
, apygplates.FeatureCollection
, astr
filename, or a (potentially nested) sequence of any combination of the above.id_type
:{
pygplates.FeatureId,
str}
, optional- By default, dictionary keys will be of type
pygplates.FeatureId
; passid_type=str
to use string representations instead.
Returns
dict
- Dictionary for looking up features by their feature ID.
N.B. the result will be an empty dictonary
if
features
is empty.
Raises
TypeError
- If
id_type
is not one of {pygplates.FeatureId
,str
}, or iffeatures
is of an invalid type. OSError (including FileNotFoundError, IsADirectoryError)
- If
features
points to a non-existent or unrecognised file.
def extract_feature(id, features)
-
Return the feature with the given feature ID.
Searches through
features
and returns the feature with a feature ID matchingid
. The order offeatures
is not preserved, so multiple features sharing the same feature ID should be avoided.Parameters
id
:pygplates.FeatureId
orstr
- The feature ID (or string representation) to search for.
features
:valid argument for pygplates.FeaturesFunctionArgument
features
may be a singlepygplates.Feature
, apygplates.FeatureCollection
, astr
filename, or a (potentially nested) sequence of any combination of the above.
Returns
pygplates.Feature
orNone
- The matching feature if found, otherwise None.
Raises
TypeError
- If
id
is not one of {pygplates.FeatureId
,str
}, or iffeatures
is of an invalid type. OSError (including FileNotFoundError, IsADirectoryError)
- If
features
points to a non-existent or unrecognised file.
def get_topological_references(features, id_type=pygplates.pygplates.FeatureId)
-
Create a dictionary mapping topological feature IDs to referenced features.
The resulting dictionary maps each topological
pygplates.FeatureId
infeatures
to the set ofpygplates.FeatureId
referenced by its topological geometry or geometries.Parameters
features
:valid argument for pygplates.FeaturesFunctionArgument
features
may be a singlepygplates.Feature
, apygplates.FeatureCollection
, astr
filename, or a (potentially nested) sequence of any combination of the above.id_type
:{
pygplates.FeatureId,
str}
, optional- By default, feature IDs will be of type
pygplates.FeatureId
; passid_type=str
to use string representations instead.
Returns
dict
- N.B. Dictionary keys include all topological features in
features
, and only topological features.
Raises
TypeError
- If
id_type
is not one of {pygplates.FeatureId
,str
}, or iffeatures
is of an invalid type. OSError (including FileNotFoundError, IsADirectoryError)
- If
features
points to a non-existent or unrecognised file.
def is_topological(feature)
-
Determine whether a feature contains a topological geometry.
Parameters
feature
:pygplates.Feature
Returns
bool
- True if
feature
contains a topological geometry, else False.
Raises
TypeError
- If
feature
is a type other thanpygplates.Feature
(more precisely, if its type does not implementget_all_topological_geometries
).