A package to handle the spherical polygon
Project description
Welcome to the SphericalPolygon package
The SphericalPolygon package is an archive of scientific routines for handling spherical polygons. Currently, operations on spherical polygons include: Currently, operations on spherical polygons include:
 calculate the area or mass(if the area density is given)
 calculate the perimeter
 identify the location of the centroid
 compute the geometrical or physical moment of inertia tensor
 determine whether one or more points are inside the spherical polygon
How to Install
SphericalPolygon can be installed with pip install sphericalpolygon
.
How to use
Create a spherical polygon
Spherical polygons can be created based on a selfdefined 2d array in form of [[lat_0,lon_0],..,[lat_n,lon_n]]
with unit of degrees or a boundary file, such as Plate boundaries for NNRMORVEL56 model. The spherical polygon has a latitude range of [90,90] and a longitude range of [180,180] or [0,360].
>>> import numpy as np >>> from sphericalpolygon import create_polygon >>> boundary = np.loadtxt('NnrMRVL_PltBndsLatLon/an',skiprows=1) # boundary for Antarctica Plate >>> polygon = create_polygon(boundary) >>> print(polygon.orientation) Counterclockwise
It shows that the orientation of the spherical polygon are counterclockwise. For more details on attributes and methods of the polygon object, please refer to polygon?
.
Calculate the area
Calculate the area(or the solid angle) of a spherical polygon over a unit sphere.
>>> print(polygon.area()) 1.4326235943514618
Calculate the area of a spherical polygon over a sphere with a radius of 6378.137km.
>>> print(polygon.area(6378.137), ' km2') 58280032.6500551 km2
Calculate the mass of a spherical polygon with an area density of 81Gt/km2 over a sphere with a radius of 6378.137km.
>>> print(polygon.area(6378.137,81), ' Gt') 4720682644.654464 Gt
Calculate the perimeter
Calculate the perimeter of a spherical polygon over a unit sphere.
>>> print(polygon.perimeter()) 6.322665894174974
Calculate the perimeter of a spherical polygon over a sphere with a radius of 6378.137km.
>>> print(polygon.perimeter(6378.137), ' km') 40326.82927827548 km
Identify the location of the centroid
Identify the centroid of a spherical polygon over a unit sphere.
>>> print(polygon.centroid()) [83.61081032380656, 57.80052886741483, 0.13827778179537997]
Identify the centroid of a spherical polygon over a sphere with a radius of 6378.137km.
>>> print(polygon.centroid(6378.137),' deg deg km') [83.61081032380656, 57.80052886741483, 881.9546363470394] deg deg km
It shows that the latitude of the centroid is close to the South Pole, and the centroid is located about 882km underground.
Compute the moment of inertia tensor
Compute the geometrical moment of inertia tensor of a spherical polygon over a unit sphere. The tensor is symmetrical and has six independent components. The first three components are located diagonally, corresponding to $Q_{11}$, $Q_{22}$, and $Q_{33}$; the last three components correspond to $Q_{12}$, $Q_{13}$, and $Q_{23}$.
>>> print(polygon.inertia()) [ 1.32669154 1.17471081 0.36384484 0.05095381 0.05246122 0.08126929]
Compute the physical moment of inertia tensor of a spherical polygon with an area density of 81Gt/km2 over a sphere with a radius of 6378.137km.
>>> print(polygon.inertia(6378.127,81)/1e12, ' Gt·Gm2') [177839.25501653 157466.66651681 48772.37278617 6830.21381414 7032.2786668 10893.9188177 ] Gt·Gm2
Points are inside the polygon？
Determine if a single point or multiple points are inside a given spherical polygon.
single point
>>> print(polygon.contains_points([75,152])) False
multiple points
>>> print(polygon.contains_points([[85,130],[35,70]])) [True, False]
Change log
 1.2.0 — Mar 20, 2020
 Added a
perimeter()
method that calculates the perimeter of a spherical polygon.  Added a
centroid()
method that determaines the centroid location for a spherical polygon.
 Added a
Reference
Chunxiao, Li. "Inertia Tensor for MORVEL Tectonic Plates." ASTRONOMICAL RESEARCH AND TECHNOLOGY 13.1 (2016).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size  File type  Python version  Upload date  Hashes 

Filename, size sphericalpolygon1.2.0py3noneany.whl (13.0 kB)  File type Wheel  Python version py3  Upload date  Hashes View 
Hashes for sphericalpolygon1.2.0py3noneany.whl
Algorithm  Hash digest  

SHA256  b038e3b43750ec56e1c58c11b4976538e506af0cab94871eaf42d9cf902b5790 

MD5  76727ad8852315e77837d0afb87655c8 

BLAKE2256  972181290462f942f42c02433ccba137b50f5e114a2e61a628053304b6fb7553 