Documentation

## Determine Area Occupied by Logical Grid Variable

This example shows how to analyze the results of logical grid manipulations to determine the area satisfying one or more conditions (either coded as 1s or an expression that yields a logical value of 1). The `areamat` function can provide the fractional surface area on the globe associated with 1s in a logical grid. Each grid element is a quadrangle, and the sum of the areas meeting the logical condition provides the total area.

Load data and use the topo grid and the greater-than relational operator to determine what fraction of the Earth lies above sea level. The answer is about 30%. (Note that land areas below sea level are excluded.)

```load topo R = georefcells(topolatlim,topolonlim,size(topo))```
```R = GeographicCellsReference with properties: LatitudeLimits: [-90 90] LongitudeLimits: [0 360] RasterSize: [180 360] RasterInterpretation: 'cells' ColumnsStartFrom: 'south' RowsStartFrom: 'west' CellExtentInLatitude: 1 CellExtentInLongitude: 1 RasterExtentInLatitude: 180 RasterExtentInLongitude: 360 XIntrinsicLimits: [0.5 360.5] YIntrinsicLimits: [0.5 180.5] CoordinateSystemType: 'geographic' AngleUnit: 'degree' ```
`a = areamat((topo>0),R)`
```a = 0.2890 ```

By default, the return value is normalized relative to the surface area of a sphere. You can obtain an unnormalized result by providing a reference spheroid as the third input. In this case, the output unit will be the square of the length unit of the reference spheroid. For example, if the reference spheroid is in kilometers, the output will be in square kilometers.

```sphericalEarth = referenceSphere('earth','km'); a = areamat((topo>0),R,sphericalEarth)```
```a = 1.4739e+08 ```

Use the `usamtx` data grid codes to find the area of a specific state within the U.S.A. As an example, determine the area of the state of Texas, which is coded as 46 in the `usamtx` grid.

```load usamtx a = areamat((map==46),refvec,referenceSphere('earth','km'))```
```a = 6.2528e+05 ```

Compute what portion of the land area of the conterminous U.S. that Texas occupies (water and bordering countries are coded with 2 and 3, respectively). This indicates that Texas occupies roughly 7.35% of the land area of the U.S

```usaland = areamat((map>3|map==1), refvec); texasland = areamat((map==46), refvec); texasratio = texasland/usaland```
```texasratio = 0.0735 ```
##### Support Get trial now