itacart.metrics.compactness

itacart.metrics.compactness(cell)[source]

Isoperimetric quotient of a cell, 4 * pi * A / p ** 2.

A transcription of equation (1) of section 2.2 of Kmoch, Vasilyev, Virro and Uuemaa (2022), Big Earth Data 6(3), 256-275. The metric is unitless, a circle scores 1, and less compact shapes fall towards zero.

A and p are planar, measured in the oblique ellipsoidal Lambert Azimuthal Equal Area projection centred on the cell’s own centroid, which is step 3 of the paper’s workflow. They are not geodesic and not measured on the sinusoidal plane. For a cell of 10 km the difference against the geodesic quantities is of the order of (d / R) ** 2, about 2e-6; the paper’s convention is kept anyway, because the purpose of the number is to be comparable with the paper’s figures.

The projection runs on the authalic latitude, whose cosine is formed from the area between the latitude and the pole, so the quotient keeps its digits near the pole, where an arcsine of a ratio within parts in a trillion of one did not.

Values to expect, all measured: a regular hexagon scores 0.9069, a square 0.7854 and an equilateral triangle 0.6046, which is the ladder the paper’s Figure 11(b) puts H3, S2 and the triangular grids on. ITACaRT cells fall between the triangular and the square grids, from 0.539 at the equator to 0.785 at row 900, where the cell is a square to five decimal places. That is the price of the 45-degree shear and it is a number to declare, not a defect to hide.

Parameters:

cell (str) – Compositional index string.

Return type:

float | list[float]

Returns:

The quotient for a single terminal cell, or a positionally aligned list when the index holds several.

Raises:
  • GeometryError – If the cell’s boundary is not a simple closed curve. The members of that class are the cells whose ring wraps the whole parallel, all of them inside the polar caps: the cell holding the pole, at every resolution – the polar cap and, below it, the one triangle per resolution that still spans the parallel – and, from resolution 4 down, many cells around that triangle whose rings wrap the parallel once or many times over. Such a ring crosses itself, so the area it encloses is not the cell’s. Step 2 of the paper’s own workflow removes cells whose geometry is invalid for exactly this kind of reason. A border trapezoid is not in it however short its base: a base too short to survive in a longitude is still a side, and the cell still has an area.

  • NonExistentCellError – If any cell of the index names no cell. The predicate is the arbiter and the contract ends there: a spelling it denies is refused rather than answered for the cell it would otherwise fold onto.