itacart.metrics.cell_max_uncertainty

itacart.metrics.cell_max_uncertainty(cell, output='radius')[source]

How far a position written as a cell can lie from the cell’s centre.

A position recorded as a cell is known to within that cell, and is read back at the cell’s representative position, its centroid – the point itacart.cells.cell_to_centroid() returns and every single-point route of the package answers with. This function measures the worst case of that substitution on the ground: the geodesic distance, on the WGS84 ellipsoid, from the centroid to the farthest vertex of the cell’s ring. It is the reach that itacart.geometry.cells_to_geometry() states for a rebuilt vertex.

Every distance is a geodesic solved by itacart.geodesy.inverse_geodesic(). A ring has three or four vertices, so a radius takes four geodesics at most and a diameter six, whatever the cell, and the cost per cell is constant. Nothing is measured on the sinusoidal plane: there every regular parallelogram is the same figure, with diagonals l and sqrt(5) l, and the measure would not see where the cell is.

On the ground the position shows. For a regular parallelogram of side l the radius follows the shear of the projection, to first order in the side:

l * max(sqrt(1 + u**2) / 2, sqrt((1 - u / 2)**2 + 1 / 4))
u = |lon * sin(lat)|, lon in radians from Greenwich, at the centroid

which is 1.118 l on the prime meridian, l / sqrt(2) where u = 1, which is where the cell is a square on the ground with a diameter of sqrt(2) l, and 1.65 l as u reaches pi. In Chukotka, east of the antimeridian, u passes pi, read on the unwrapped longitude the package returns past 180 degrees. A finite cell departs from the law in proportion to its side. Over the regular parallelograms of resolution-1 rows 943 and 990 to 998 in the four quadrants and of the cells past the antimeridian in three rows of Chukotka, and over a lattice in latitude and u at resolutions 2 to 13 that reaches the top of row 998 and u past pi, the radius exceeds the law by at most 4.2e-3 * l / 10 km below 85 degrees of latitude and 0.2 * l / 10 km from 85 degrees to row 998, plus up to 1e-6 from the rounding of the coordinates, which is what sets the departure below 85 degrees from resolution 11 down. It never falls short of the law by more than that rounding. In a parallelogram the diameter is twice the radius within the same bound. In a triangle, a trapezoid or a cap it is not, and no relation between the two is claimed there.

The maxima are taken at the vertices, not over the continuous boundary. The two agree, to the rounding of the coordinates, in every family measured – interior, border, polar row, extension, the cells the quantizer answers with near each pole at every resolution, and every cell of the caps’ physical refinement down to resolution 5 – with one exception at every resolution: the cell that holds a pole. Its base is a whole parallel and its two base vertices, at -180 and +180 degrees, are one point, so its diameter over the vertices is half the diameter of its boundary, 0.196573 l against 0.393146 l at resolution 1. Its radius agrees. Under a cap, a spelling outside the cap’s physical refinement can also reach further along its boundary than at its vertices. Over the whole subtree at resolution 4, with every edge cut into eight, the boundary’s radius reaches 1.156 times the vertices’ and its diameter 1.825 times; in a sample at resolution 5, 2.648 and 3.916 times. Finer cutting can only find more.

The number is a property of the tessellation and not the accuracy of a survey: it says how far the cell’s centre can be from a position the cell holds, not how well that position was measured.

Parameters:
  • cell (str) – Compositional index string.

  • output (Literal['radius', 'diameter', 'ratio'], default: "radius") – "radius", the default, for the distance from the centroid to the farthest vertex, in metres; "diameter" for the largest distance between two vertices, in metres; or "ratio" for the radius over itacart.resolutions.cell_size() of the cell’s resolution, unitless.

Return type:

float | list[float]

Returns:

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

Raises:
  • GeometryError – If output is not one of the three named forms.

  • 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.