How to calculate the area of plates with specified plateId in pygplates?

Hi all,

I know that in Gplates, it is easy to get the area of a given plate. In pygplates, we can also get the area of a polygon using get_area().

My question is, is there a function like this in pygplates that we can use to get the area of the plate for a given id?

Thank you!

Hi Goco,

You’d first need to search through the plate features for the given plate ID and then find its area.

So something like:

plate_id = ...
plate_features = ...

for plate in plate_features:
  if plate.get_reconstruction_plate_id() == plate_id:
    plate_area_in_sq_kms = (plate.get_geometry.get_area() *
        pygplates.Earth.mean_radius_in_kms *
        pygplates.Earth.mean_radius_in_kms)
    print('Plate area: {}'.format(plate_area_in_sq_kms))

And if they’re not all polygons (for some reason) then get_area() will error (eg, it won’t work on a polyline), so you’d also need to test the geometry type before calling it. Also a single plate feature could potentially contain more than one geometry, so might be better to iterate over a feature’s get_geometries() (instead of a single geometry with get_geometry()).

1 Like

It works, thank you John!