area
Syntax
Description
Examples
Read world lakes into the workspace as a geospatial table. Extract the polygon shapes.
lakes = readgeotable("worldlakes.shp");
shape = lakes.Shapeshape=37×1 geopolyshape array with properties:
NumRegions: [37×1 double]
NumHoles: [37×1 double]
Geometry: "polygon"
CoordinateSystemType: "geographic"
GeographicCRS: [1×1 geocrs]
⋮
Calculate the areas of the polygon shapes.
A = area(shape);
The units depend on the geographic coordinate reference system (CRS) for the shape. Find the length unit for the geographic CRS. The result indicates that the areas are in square meters.
shape.GeographicCRS.Spheroid.LengthUnit
ans = 'meter'
Include the areas in the geospatial table by creating a new table variable. Sort the rows of the table in descending order by Area. Then, view the first eight rows of the table by using the head function.
lakes.Area = A; lakes = sortrows(lakes,"Area","descend"); head(lakes)
Shape Name Area
____________ _________________________________ __________
geopolyshape "Caspian Sea" 3.9124e+11
geopolyshape "Lakes Superior, Michigan, Huron" 2.0459e+11
geopolyshape "Lake Victoria" 7.0562e+10
geopolyshape "Aral Sea" 6.3581e+10
geopolyshape "Lake Baikal" 3.3211e+10
geopolyshape "Great Bear Lake" 3.2114e+10
geopolyshape "Lake Tanganyika" 3.0947e+10
geopolyshape "Lake Malawi" 3.0596e+10
Read hydrographic data for Concord, MA into the workspace as a geospatial table. Extract the polygon shapes.
hydro = readgeotable("concord_hydro_area.shp");
shape = hydro.Shapeshape=98×1 mappolyshape array with properties:
NumRegions: [98×1 double]
NumHoles: [98×1 double]
Geometry: "polygon"
CoordinateSystemType: "planar"
ProjectedCRS: [1×1 projcrs]
⋮
Calculate the areas of the polygon shapes.
A = area(shape);
The units depend on the projected coordinate reference system (CRS) for the shape. Find the length unit for the projected CRS. The result indicates that the areas are in square meters.
shape.ProjectedCRS.LengthUnit
ans = "meter"
Create a new geospatial table from the shape objects and the areas. View the first eight rows of the table by using the head function.
hydro_area = table(shape,A,VariableNames=["Shape","Area"]); head(hydro_area)
Shape Area
____________ __________
mappolyshape 2456.4
mappolyshape 1.2685e+05
mappolyshape 2075.4
mappolyshape 814.05
mappolyshape 10754
mappolyshape 5894.2
mappolyshape 48368
mappolyshape 27673
Input Arguments
Polygon shape, specified as a geopolyshape
object, a mappolyshape
object, an array of geopolyshape objects, or an array of
mappolyshape objects.
Output Arguments
Area, returned as an array. The size of A matches the size of
shape.
The units of A depend on the type of polygon shape.
When
shapecontainsgeopolyshapeobjects, the length unit of the reference ellipsoid for the shape determines the units. To find the length unit, get thegeocrsobject for the shape by querying theGeographicCRSproperty of the shape object. Then, get the ellipsoid by querying theSpheroidproperty of thegeocrsobject. If the ellipsoid is areferenceEllipsoidorreferenceSphereobject, then query theLengthUnitproperty of the ellipsoid. For a shapeshp, the length unit isshp.GeographicCRS.Spheroid.LengthUnit. If theGeographicCRSproperty of the object is empty, the function calculates the area using the WGS84 reference ellipsoid and a length unit of meters.When
shapecontainsmappolyshapeobjects, the length unit of the projected coordinate reference system for the shape determines the units. To find the length unit, get theprojcrsobject for the shape by querying theProjectedCRSproperty of the shape object. Then, query theLengthUnitproperty of theprojcrsobject. For a shapeshp, the length unit isshp.ProjectedCRS.LengthUnit.
When shape contains geopolyshape objects, the
area function calculates the areas using geodesics.
Data Types: double
Limitations
The area function does not support some large polygons that cover
more than a hemisphere.
Tips
The accuracy of the area function depends on the
resolution of the data used to create the polygons. As a result, the function can return
different results when you use polygon shapes from different data sets as inputs. This image
compares the areas of polygon shapes for the state of Florida from two data sets.

Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)