Usage Note 22772: How can I calculate the area inside a polygon?
The program below can be used to calculate the area inside a polygon. The data set TESTPOLY contains 5 points defining a sample polygon. You should replace TESTPOLY with a data set containing X and Y coordinates for the polygon whose area you want to calculate (with each set of points in the polygon being a set of X and Y variables).
Note the following when using the program:
- The program cannot be used with self-intersecting polygons (that is, a polygon whose boundaries cross each other).
- If you are using map data, the data should be projected.
- If you are using projected map data, the coordinates will most likely be in arbitrary units. You will probably want to convert the units to some standard measure, such as miles or meters, before calculating the area.
/* Boundaries of a Test Polygon. */
data testpoly;
x1=4; y1=4;
x2=8; y2=4;
x3=8; y3=8;
x4=4; y4=8;
x5=4; y5=4;
run;
data area;
retain area 0;
array x(5) x1-x5;
array y(5) y1-y5;
set testpoly;
do i=1 to 4;
j=(i+1);
area = area + ( x(i)*y(j) );
area = area - ( x(j)*y(i) );
end;
area=area/2;
stop;
run;
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
| Type: | Usage Note |
| Priority: | low |
| Topic: | SAS Reference ==> Procedures ==> GMAP
|
| Date Modified: | 2019-06-06 09:47:13 |
| Date Created: | 2002-12-16 10:56:43 |