This example shows how to calculate geographic areas for vector data in polygon format using the
areaint performs a numerical integration using Green's Theorem for the area on a surface enclosed by a polygon. Because this is a discrete integration on discrete data, the results are not exact. Nevertheless, the method provides the best means of calculating the areas of arbitrarily shaped regions. Better measures result from better data. For more information, see
Load the continental United States MAT-file,
conus.mat , and calculate the radius of the Earth.
load conus earthradius = almanac('earth','radius');
Calculate the area of the continental United States, along with the area of Long Island and Martha's Vineyard.
areaint like the other area functions,
areamat, returns the area as a fraction of the entire planet's surface, unless you provide a radius. Because the default Earth radius is in kilometers, the area is in square kilometers.
area = areaint(uslat,uslon,earthradius)
area = 3×1 106 × 7.9256 0.0035 0.0004
Calculate the areas of the Great Lakes using the same variables, this time in square miles.
areaint returns three areas: the largest for the polygon representing Superior, Michigan, and Huron together, the other two for Erie and Ontario.
earthradius = almanac('earth','radius','miles'); area = areaint(gtlakelat,gtlakelon,earthradius)
area = 3×1 104 × 8.0120 1.0382 0.7634