This example demonstrates how to save the reconstructed data to shapefiles.¶
The "get_" methods of PlotTopologies class return GeoDataFrame objects whose to_file() method can be used to save the data to other file formats, check out the GeoDataFrame doc.
In [1]:
import os
from pathlib import Path
from gplately import auxiliary
# use the auxiliary function to create a PlotTopologies instance
gplot = auxiliary.get_gplot("Zahirovic2022", time=100) # 100Ma
# get GeoDataFrame objects and save them to shapefiles
data_dir = Path("gplately-example-data") / "07-SaveReconstructedData"
data_dir.mkdir(parents=True, exist_ok=True)
gplot.get_continents().to_file(f"{data_dir}/continents_100Ma.shp")
gplot.get_coastlines().to_file(f"{data_dir}/coastlines_100Ma.shp")
gplot.get_topological_plate_boundaries().to_file(
f"{data_dir}/topological_plate_boundaries_100Ma.shp"
)
print(f"The files have been saved in folder {data_dir}.")
The files have been saved in folder gplately-example-data/07-SaveReconstructedData.
In [2]:
# list the created files in the `gplately-example-data` folder and print their names.
# sort the files by name to make sure the order is consistent across different operating systems.
for filename in sorted(os.listdir(data_dir)):
if (
filename.startswith("continents_100Ma")
or filename.startswith("coastlines_100Ma")
or filename.startswith("topological_plate_boundaries_100Ma")
):
print(f" - {filename}")
- coastlines_100Ma.cpg - coastlines_100Ma.dbf - coastlines_100Ma.prj - coastlines_100Ma.shp - coastlines_100Ma.shx - continents_100Ma.cpg - continents_100Ma.dbf - continents_100Ma.prj - continents_100Ma.shp - continents_100Ma.shx - topological_plate_boundaries_100Ma.cpg - topological_plate_boundaries_100Ma.dbf - topological_plate_boundaries_100Ma.prj - topological_plate_boundaries_100Ma.shp - topological_plate_boundaries_100Ma.shx