Hi vishesh,
You can actually get pyGPlates to read/write Shapefiles (as opposed to pulling out the geometries yourself). To reconstruct a Shapefile from present day (0 Ma) to a past time you can use code like this example:
Exported reconstructed features to a file
…which can be simplified to just:
pygplates.reconstruct(import_shapefilename, rotation_files, export_shapefilename, reconstruction_time)
…which reads import_shapefilename, reconstructs it to reconstruction_time using one or more rotation_files and writes the results to export_shapefilename.
That’s because the geometries in the Shapefile have yet to be assigned plate IDs which, along with the rotation file, tell GPlates/pyGPlates how to rotate the geometries.
You’ll need some polygons with plate IDs to do that. You can assign plate IDs in GPlates (see Tutorial 1.5: Creating Features - example 3).
Alternatively you can assign plate IDs using pyGPlates (see Import geometries and assign plate IDs). Those examples assume you’re importing geometries from a text file, so you can ignore that part and just do:
assigned_features = pygplates.partition_into_plates(
static_polygons_filename,
rotation_files,
import_shapefilename,
properties_to_copy = [
pygplates.PartitionProperty.reconstruction_plate_id,
pygplates.PartitionProperty.valid_time_period],
reconstruction_time = 0)
…and then save the assigned features back to your Shapefile (overwriting it):
pygplates.FeatureCollection(assigned_features).write(import_shapefilename)
Now that you have a Shapefile with assigned plate IDs, you can use the pygplates.reconstruct function as described above.
Normally feature collections store their geometries in present day coordinates. All the above code assumes this. So if your “from age” is not present day (and hence the geometries in your Shapefile are not at present day) then it’s best to reverse reconstruct your Shapefile to present day by doing something like this:
pygplates.reverse_reconstruct(import_shapefilename, rotation_files, from_age)
…which will read import_shapefilename, reverse reconstruct from from_age to 0 Ma and write the result back to import_shapefilename.
Note that you should do this after you assign plate IDs because the plate IDs also tell pyGPlates how to reverse reconstruct. So your final code could look like:
assigned_features = pygplates.partition_into_plates(
static_polygons_filename,
rotation_files,
import_shapefilename,
properties_to_copy = [
pygplates.PartitionProperty.reconstruction_plate_id,
pygplates.PartitionProperty.valid_time_period],
reconstruction_time = from_age)
pygplates.reverse_reconstruct(assigned_features, rotation_files, from_age)
pygplates.FeatureCollection(assigned_features).write(import_shapefilename)
…note that reconstruction_time = from_age is specified in the call to pygplates.partition_into_plates, which reconstructs the static polygons to from_age and then partitions your geometries using that configuration (noting that your geometries are already at from_age). Then your geometries are reverse reconstructed back to present day (with the pygplates.reverse_reconstruct call).
Then you can reconstruct to any to_age and store the result in export_shapefilename.
pygplates.reconstruct(import_shapefilename, rotation_files, export_shapefilename, to_age)
Regards,
John