1PLANIMETER(1)               GeographicLib Utilities              PLANIMETER(1)
2
3
4

NAME

6       Planimeter -- compute the area of geodesic polygons
7

SYNOPSIS

9       Planimeter [ -r ] [ -s ] [ -l ] [ -e a f ] [ -w ] [ -p prec ] [ -G | -E
10       | -Q | -R ] [ --comment-delimiter commentdelim ] [ --version | -h |
11       --help ] [ --input-file infile | --input-string instring ] [
12       --line-separator linesep ] [ --output-file outfile ]
13

DESCRIPTION

15       Measure the area of a geodesic polygon.  Reads polygon vertices from
16       standard input, one per line.  Vertices may be given as latitude and
17       longitude, UTM/UPS, or MGRS coordinates, interpreted in the same way as
18       GeoConvert(1).  (MGRS coordinates signify the center of the
19       corresponding MGRS square.)  The end of input, a blank line, or a line
20       which can't be interpreted as a vertex signals the end of one polygon
21       and the start of the next.  For each polygon print a summary line with
22       the number of points, the perimeter (in meters), and the area (in
23       meters^2).
24
25       The edges of the polygon are given by the shortest geodesic between
26       consecutive vertices.  In certain cases, there may be two or many such
27       shortest geodesics, and in that case, the polygon is not uniquely
28       specified by its vertices.  This only happens with very long edges (for
29       the WGS84 ellipsoid, any edge shorter than 19970 km is uniquely
30       specified by its end points).  In such cases, insert an additional
31       vertex near the middle of the long edge to define the boundary of the
32       polygon.
33
34       By default, polygons traversed in a counter-clockwise direction return
35       a positive area and those traversed in a clockwise direction return a
36       negative area.  This sign convention is reversed if the -r option is
37       given.
38
39       Of course, encircling an area in the clockwise direction is equivalent
40       to encircling the rest of the ellipsoid in the counter-clockwise
41       direction.  The default interpretation used by Planimeter is the one
42       that results in a smaller magnitude of area; i.e., the magnitude of the
43       area is less than or equal to one half the total area of the ellipsoid.
44       If the -s option is given, then the interpretation used is the one that
45       results in a positive area; i.e., the area is positive and less than
46       the total area of the ellipsoid.
47
48       Only simple (i.e., non-self-intersecting) polygons are supported for
49       the area computation.  Polygons may include one or both poles.  There
50       is no need to close the polygon.
51

OPTIONS

53       -r  toggle whether counter-clockwise traversal of the polygon returns a
54           positive (the default) or negative result.
55
56       -s  toggle whether to return a signed result (the default) or not.
57
58       -l  toggle whether the vertices represent a polygon (the default) or a
59           polyline.  For a polyline, the number of points and the length of
60           the path joining them is returned; the path is not closed and the
61           area is not reported.
62
63       -e a f
64           specify the ellipsoid via the equatorial radius, a and the
65           flattening, f.  Setting f = 0 results in a sphere.  Specify f < 0
66           for a prolate ellipsoid.  A simple fraction, e.g., 1/297, is
67           allowed for f.  By default, the WGS84 ellipsoid is used, a =
68           6378137 m, f = 1/298.257223563.  If entering vertices as UTM/UPS or
69           MGRS coordinates, use the default ellipsoid, since the conversion
70           of these coordinates to latitude and longitude always uses the
71           WGS84 parameters.
72
73       -w  toggle the longitude first flag (it starts off); if the flag is on,
74           then when reading geographic coordinates, longitude precedes
75           latitude (this can be overridden by a hemisphere designator, N, S,
76           E, W).
77
78       -p prec
79           set the output precision to prec (default 6); the perimeter is
80           given (in meters) with prec digits after the decimal point; the
81           area is given (in meters^2) with (prec - 5) digits after the
82           decimal point.
83
84       -G  use the series formulation for the geodesics.  This is the default
85           option and is recommended for terrestrial applications.  This
86           option, -G, and the following three options, -E, -Q, and -R, are
87           mutually exclusive.
88
89       -E  use "exact" algorithms (based on elliptic integrals) for the
90           geodesic calculations.  These are more accurate than the (default)
91           series expansions for |f| > 0.02.  (But note that the
92           implementation of areas in GeodesicExact uses a high order series
93           and this is only accurate for modest flattenings.)
94
95       -Q  perform the calculation on the authalic sphere.  The area
96           calculation is accurate even if the flattening is large, provided
97           the edges are sufficiently short.  The perimeter calculation is not
98           accurate.
99
100       -R  The lines joining the vertices are rhumb lines instead of
101           geodesics.
102
103       --comment-delimiter commentdelim
104           set the comment delimiter to commentdelim (e.g., "#" or "//").  If
105           set, the input lines will be scanned for this delimiter and, if
106           found, the delimiter and the rest of the line will be removed prior
107           to processing.  For a given polygon, the last such string found
108           will be appended to the output line (separated by a space).
109
110       --version
111           print version and exit.
112
113       -h  print usage and exit.
114
115       --help
116           print full documentation and exit.
117
118       --input-file infile
119           read input from the file infile instead of from standard input; a
120           file name of "-" stands for standard input.
121
122       --input-string instring
123           read input from the string instring instead of from standard input.
124           All occurrences of the line separator character (default is a
125           semicolon) in instring are converted to newlines before the reading
126           begins.
127
128       --line-separator linesep
129           set the line separator character to linesep.  By default this is a
130           semicolon.
131
132       --output-file outfile
133           write output to the file outfile instead of to standard output; a
134           file name of "-" stands for standard output.
135

EXAMPLES

137       Example (the area of the 100km MGRS square 18SWK)
138
139          Planimeter <<EOF
140          18n 500000 4400000
141          18n 600000 4400000
142          18n 600000 4500000
143          18n 500000 4500000
144          EOF
145          => 4 400139.53295860 10007388597.1913
146
147       The following code takes the output from gdalinfo and reports the area
148       covered by the data (assuming the edges of the image are geodesics).
149
150          #! /bin/sh
151          egrep '^((Upper|Lower) (Left|Right)|Center) ' |
152          sed -e 's/d /d/g' -e "s/' /'/g" | tr -s '(),\r\t' ' ' | awk '{
153              if ($1 $2 == "UpperLeft")
154                  ul = $6 " " $5;
155              else if ($1 $2 == "LowerLeft")
156                  ll = $6 " " $5;
157              else if ($1 $2 == "UpperRight")
158                  ur = $6 " " $5;
159              else if ($1 $2 == "LowerRight")
160                  lr = $6 " " $5;
161              else if ($1 == "Center") {
162                  printf "%s\n%s\n%s\n%s\n\n", ul, ll, lr, ur;
163                  ul = ll = ur = lr = "";
164              }
165          }
166          ' | Planimeter | cut -f3 -d' '
167

SEE ALSO

169       GeoConvert(1), GeodSolve(1).
170
171       An online version of this utility is availbable at
172       <https://geographiclib.sourceforge.io/cgi-bin/Planimeter>.
173
174       The algorithm for the area of geodesic polygon is given in Section 6 of
175       C. F. F. Karney, Algorithms for geodesics, J. Geodesy 87, 43-55 (2013);
176       DOI <https://doi.org/10.1007/s00190-012-0578-z>; addenda:
177       <https://geographiclib.sourceforge.io/geod-addenda.html>.
178

AUTHOR

180       Planimeter was written by Charles Karney.
181

HISTORY

183       Planimeter was added to GeographicLib,
184       <https://geographiclib.sourceforge.io>, in version 1.4.
185
186
187
188GeographicLib 1.49                2017-10-05                     PLANIMETER(1)
Impressum