SHAPELY_AREA
Computes the planar area of a geometry provided as Well-Known Text (WKT). This is most meaningful for polygonal geometries; for points and lines, the area is 0.
For a polygonal region G, area is computed as:
A = \iint_G 1\, dA
The function parses the input WKT into a Shapely geometry and returns the resulting numeric area.
Excel Usage
=SHAPELY_AREA(geometry)
geometry(str, required): WKT string representation of the geometry.
Returns (float): Area of the geometry.
Example 1: Area of a unit square
Inputs:
| geometry |
|---|
| POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) |
Excel formula:
=SHAPELY_AREA("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")
Expected output:
1
Example 2: Area of a rectangle
Inputs:
| geometry |
|---|
| POLYGON ((0 0, 4 0, 4 2, 0 2, 0 0)) |
Excel formula:
=SHAPELY_AREA("POLYGON ((0 0, 4 0, 4 2, 0 2, 0 0))")
Expected output:
8
Example 3: Area of a point
Inputs:
| geometry |
|---|
| POINT (10 20) |
Excel formula:
=SHAPELY_AREA("POINT (10 20)")
Expected output:
0
Example 4: Area of a multipolygon
Inputs:
| geometry |
|---|
| MULTIPOLYGON (((0 0, 2 0, 2 2, 0 2, 0 0)), ((3 0, 4 0, 4 1, 3 1, 3 0))) |
Excel formula:
=SHAPELY_AREA("MULTIPOLYGON (((0 0, 2 0, 2 2, 0 2, 0 0)), ((3 0, 4 0, 4 1, 3 1, 3 0)))")
Expected output:
5
Python Code
from shapely import wkt
def shapely_area(geometry):
"""
Calculate the area of a geometry.
See: https://shapely.readthedocs.io/en/stable/reference/shapely.area.html
This example function is provided as-is without any representation of accuracy.
Args:
geometry (str): WKT string representation of the geometry.
Returns:
float: Area of the geometry.
"""
try:
if not geometry:
return 0.0
geom = wkt.loads(geometry)
return float(geom.area)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
WKT string representation of the geometry.