GPlates / gplately

GPlately is a Python package to interrogate tectonic plate reconstructions.
https://gplates.github.io/gplately/
GNU General Public License v2.0
56 stars 13 forks source link

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

Closed tom-new closed 4 months ago

tom-new commented 10 months ago

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)
jcannon-gplates commented 10 months ago

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.

michaelchin commented 4 months ago

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