How to quantify unevenness of polygon boundaries?

I have two polygons: Polygon 1 and Polygon 2.

Using two metrics, area and perimeter length, I want to express quantitatively that Polygon 1 has a more uneven/jagged/irregular perimeter than Polygon 2.

Each polygon has the same perimeter length but each covers quite different areas. To quantify the unevenness/jaggedness/irregularity of each polygon, should the calculation be:

area/perimeter

or

perimeter/area

I thought perimeter/area, but then I found this blog post which uses area/perimeter : http://www.r-bloggers.com/measuring-the-gerrymander-with-spatstat/

-
Neither of those ratios makes sense, because they both depend on the units of measurement. You can make them independent of the units by forming a zero-degree homogeneous function of them such as perimeter/sqrt(area). Such measurements are often referred to as "tortuosity." Some other approaches can be found by searching our site on tortuosity. – whuber Jun 8 '13 at 17:45
What is the question? F1(X)/F2(Y) or F2(Y)/F1(X) aren't different measures, in the same way that a isn't a different measure to 1/a. – BradHards Jun 9 '13 at 5:56
@Bradhards Many people would contend a and 1/a are different ways of expressing the same underlying quantity, even though there is a mathematical relationship between them. The nonlinearity of this relationship implies this is no mere change of units. The two expressions should be considered genuinely different, just as (say) log concentration and concentration are different ways to express concentration, or miles per gallon and gallons per mile are essentially different ways of expressing fuel economy. (And note that gallons per mile would be interpreted as wastefulness, not "economy.") – whuber Jun 9 '13 at 14:01

Take a look at a program called FRAGSTATS (http://www.umass.edu/landeco/research/fragstats/downloads/fragstats_downloads.html). In the patch metrics section it mentions “Fractal Dimension Index” which the notes state “Fractal dimension index is appealing because it reflects shape complexity across a range of spatial scales (patch sizes). Thus, like the shape index (SHAPE), it overcomes one of the major limitations of the straight perimeter-area ratio as a measure of shape complexity.” (http://www.umass.edu/landeco/research/fragstats/documents/Metrics/Shape%20Metrics/Metrics/P9%20-%20FRAC.htm).

-
I would add that the formula to calculate the Fractal Dimension Index looks simple to calculate without needing the FRAGSTATS software itself. The formula is shown in the link above. Fractal Dimension Index approaches 1 for shapes with very simple perimeters such as squares, and approaches 2 for very complex shapes. – user14134 Jun 12 '13 at 10:50

The relationship of area to perimeter doesn't mean much, a square and a rectangle would probably be taken to have equal jaggedness but they could have the same perimeter and the farther from square the rectangle is, the less the area.

To calculate "jaggedness" I think you need to know how many of the vertices are at angles greater than 180 degrees. This should not be too hard to calculate if you are using a geometry store where the direction of rotation of the polygon is known (typically counterclockwise, in which case if you go from point 1 to point 2, the angle exceeds 180 degrees if point 3 is to the right of the line defined by points 1 and 2). Otherwise you need to determine rotation first.

-
This is basically what I was thinking. Some kind of "count" of sharp angles on the perimeter. – Baltok Jun 10 '13 at 13:37
The problem with this proposal is that it depends on how the shape is represented more than it does on the shape itself, which makes it arbitrary and unreliable. For instance, one could replace every sharp point on a shape by a sequence of two very closely spaced vertices having angles less than 180 degrees without visibly modifying the shape. The importance of this reply lies in pointing out that the question cannot be answered without having an operational description of what "jaggedness" is supposed to mean. – whuber Jun 10 '13 at 13:54
I'm assuming that "jagged" means "with concavity". The jagged example above has a number of concavities. Taking that as the operational description, there is no way to create a concavity in a polygon without creating an angle that is greater than 180 degrees with respect to the direction of rotation of the vertices of the polygon – Russell at ISC Jun 10 '13 at 15:10
I'm also assuming the polygon is not self-intersecting. – Russell at ISC Jun 10 '13 at 15:17
@Russell That's fine but it still doesn't work. A "concavity" could be represented by a single vertex or by a sequence of thousands of closely spaced concave vertices (which happens, for instance, when the feature is created by subtracting buffers of other features). Once again, the problem is that your proposal depends on irrelevant details of representation of the shape rather than on inherent properties of the shape itself. This can be overcome in many ways by estimating fractal dimension or total absolute curvature, etc, but your answer doesn't seem to be going in that direction. – whuber Jun 12 '13 at 12:13

Try the Normalized Perimeter Index (http://clear.uconn.edu/tools/Shape_Metrics/). The normalized perimeter index uses the equal area circle to normalize the metric. Thus the formula is effectively (in Python, import math) `normPeriIndex = (2*math.sqrt(math.pi*Area))/perimeter`