Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Spherical Polygons and Areas

Authors
Affiliations
NSF National Center for Atmospheric Research
Tiling of the sphere by spherical triangles

Spherical Polygons and Areas


Overview

In this notebook, we will calculate how to use spherical polygons on a sphere to determine areas and perimeters.

  • Calculate area and permieter of quadrilateral patch on a sphere

  • Determine if a given point is within a spherical polygon

  • Mean center of spherical polygon

Prerequisites

ConceptsImportanceNotes
NumpyNecessaryUsed to work with large arrays
PandasNecessaryUsed to read in and organize data (in particular dataframes)
Intro to CartopyHelpfulWill be used for adding maps to plotting
MatplotlibHelpfulWill be used for plotting
  • Time to learn: 20 minutes


Imports

  • Import Packages

  • Setup location dataframe with coordinates

Loading...

Area and Perimeter of quadrilateral patch

We can make use of the pyproj Python package to calculate the area and perimeter of a patch formed by a list of latitude and longitude coordinates for an ellipsoid or a sphere.

Let’s compare how area and perimeter vary based on whether you use an ellpsoid like WGS-84 and a sphere. The changes will become more pronounced as you move further towards the poles.

Area Ellipsoid   = 5342585.6476998255 km^2
Area Sphere = 5344606.94796931 km^2
Perimeter Ellipsoid = 10171.738963248145 km
Perimeter Sphere = 10170.504728302833 km
Roughly 1.05% of the Earth's Surface
Roughly 1.05% of the Earth's Surface

Plot Area of Quadrilateral Patch

Let’s see what spherical polygons looks like on a world map!

Ellipsoid Area   = 21872449.378265787 km^2
Sphere Area = 21896220.663299154 km^2
<Figure size 1500x1000 with 2 Axes>
Ellipsoid Area   = 3150946.426714995 km^2
Sphere Area = 3149017.3086414044 km^2
<Figure size 1500x1000 with 2 Axes>
Ellipsoid Area   = 3788155.432965353 km^2
Sphere Area = 3782548.632737316 km^2
<Figure size 1500x1000 with 2 Axes>
Ellipsoid Area   = 914381.1786067598 km^2
Sphere Area = 954445.989927043 km^2
<Figure size 1500x1000 with 2 Axes>

Determine if a given point is within a spherical polygon

Now that we have a spherical polygon, how can be determine if a new point lies within the area of the polygon? The shapely Python package makes this quite easy, let’s give it a shot!

array([ True])

Plot and See if New Point within Polygon

On a map, it can be fairly intuitive to see if a point lies within a polygon or not. Let’s give it a shot!

array([ True])
<Figure size 1500x1000 with 2 Axes>
array([False])
<Figure size 1500x1000 with 2 Axes>
<Figure size 1500x1000 with 2 Axes>
<Figure size 1500x1000 with 2 Axes>

Mean center of spherical polygon

A spherical polygon can have a fairly regular shape, especially as more points are added. But it is fairly simple using the shapley Python package to determine the mean center.

(37.30896666666666, -90.47586666666665)

Plot Centroid

The center of a polygon can be fairly apparently on a map, let’s give it a look!

<Figure size 1500x1000 with 2 Axes>
<Figure size 1500x1000 with 2 Axes>

Summary

This notebook covers working with spherical polygons to determine the ordering of coordinates, center of polygons, and whether or not a point lies within a spherical polygon

Resources and references