Module gplately.ptt.convert_xy_to_gplates
Functions
def import_geometry_from_xy_file(input_geometry_filename, multi_geometry_type=pygplates.pygplates.PolylineOnSphere, lon_lat_order=True, scalar_types=None)
-
Parse ascii file containing latitude/longitude geometries.
Returns a list of imported features, or None on parse error.
If an input ascii file contains '>' separators at the beginning of lines then these indicate a new geometry (there can be multiple consecutive '>' lines with arbitrary text, or feature metadata, to delineate two geometries). If there is only one 'lon lat' line between '>' markers then a point geometry is created. Multiple consecutive 'lon lat' lines are combined into a single polyline (or multipoint/polygon depending on multi-geometry type specified). For example, the following is one point geometry and one line geometry:
This is a point geometry… 0 0 This is a polyline (or multipoint/polygon) geometry… 0 0 0 10
Furthermore, each line starting with '>' can optionally contain arbitrary text, or feature metadata. Feature metadata can be the type of feature or a feature property. The following example shows all currently supported metadata…
An arbitrary text line does not contain the '=' character. Whereas each metadata text line looks like 'name=value'…
FeatureType = Coastline Name = Australia Description = Australian coastline ReconstructionPlateId = 801 ValidTime = (4540, -inf) 141.6863 -12.5592 …
…where all metadata is optional. If 'FeatureType' is not specified then it defaults to an 'unclassified' feature. Note that 'ValidTime' supports 'inf' and '-inf' which represent distant past and future respectively.
If there are no '>' markers (ie, not actually a GMT '.xy' file) then each point will be a separate geometry (instead of one large polyline geometry), except if the multipoint type is 'pygplates.MultiPointOnSphere' (which results in one large multipoint). This treats the ascii file simply as a list of points. For example, the following is three point geometries:
0 0 0 10 0 20
By default a GMT '.xy' file has lon/lat order. Specifying 'lon_lat_order' as False changes this to lat/lon order.
Specify 'scalar_types' to convert extra scalar values to coverage data. If 'scalar_types' is specified it should be a sequence of 'pygplates.ScalarType' instances. Each line in the file containing a point has a longitude and a latitude value as a minimum. Extra values are scalar values associated with each point. This option specifies the scalar types of each extra field. For example:
import_geometry_from_xy_file( 'geometries.xy', scalar_types = [ pygplates.ScalarType.create_gpml('SpreadingRate'), pygplates.ScalarType.create_gpml('SpreadingDirection'), pygplates.ScalarType.create_gpml('SpreadingAsymmetry')])
…could represent three extra scalar values for each point (in that order). So a line containing:
10 20 15 80 48
…would have longitude=10, latitude=20, SpreadingRate=15, SpreadingDirection=80 and SpreadingAsymmetry=48.