www.gusucode.com > map 案例源码 matlab代码程序 > map/DetermineAreaOccupiedByLogicalGridVariableExample.m
%% 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.) % Copyright 2015 The MathWorks, Inc. load topo R = georefcells(topolatlim,topolonlim,size(topo)) a = areamat((topo>0),R) %% % 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) %% % 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')) %% % 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