gplately icon indicating copy to clipboard operation
gplately copied to clipboard

[Feature Request] Allow FeatureCollection to accept a sequence of strings as input

Open tom-new opened this issue 2 years ago • 1 comments

As RotationModel allows, it would be convenient if FeatureCollection accepted a sequence of strings as input such that

topology_filenames = ["topology1.gpmlz", "topology2.gpmlz"]
topology_features = pygplates.FeatureCollection()
for topology_filename in topology_filenames:
	topology_features.add(pygplates.FeatureCollection(topology_filename))

could be replaced with the more succinct

topology_filenames = ["topology1.gpmlz", "topology2.gpmlz"]
topology_features = pygplates.FeatureCollection(topology_filenames)

tom-new avatar Dec 05 '23 02:12 tom-new

This is similar to merging multiple files into a single file (which can be saved with FeatureCollection.write(filename). However we've tended to discourage this for various reasons - eg, combining two Shapefiles with different attribute tables and then loading that into GPlates/pyGPlates can create problems (eg, error messages about key-value dictionaries).

As you noted, the user can still combine them if they wish, but they have to do it explicitly.

jcannon-gplates avatar Dec 05 '23 02:12 jcannon-gplates

This can be done in gplately with a class method now. See the code below.

https://github.com/GPlates/gplately/blob/58ca1b000142931082f1ae1528ae42dc26ff6722/gplately/pygplates.py#L385-L402

michaelchin avatar May 12 '24 06:05 michaelchin