Cell Geometry

Everything geometric about a cell is derived from its index. Nothing is stored, and nothing is looked up.

import itacart
cell = "SE(1400/0374)"
itacart.cell_to_boundary(cell, close=True)
[(151.16329086302792, -33.786680997684385),
 (151.21397164520369, -33.87683659195477),
 (151.3220588300823, -33.87683659195477),
 (151.2712646422158, -33.786680997684385),
 (151.16329086302792, -33.786680997684385)]

Five positions: four distinct vertices and a repeat of the first, which closes the ring. Longitude first, then latitude, in EPSG:4326.

From index to vertices

Descending the index arrives at the anchor — the lattice corner the address inverts to exactly. The other three vertices follow from the construction: base length \(l\) along the parallel, height \(l\) along the meridian, and the lean that carries the upper edge one base-length to the west. The Sinusoidal Construction is where those coordinates come from.

itacart.cell_to_anchor(cell), itacart.cell_to_centroid(cell)
((151.16329086302792, -33.786680997684385),
 (151.24258658784686, -33.831758959864835))

The two points are different and both are meaningful — the anchor is the lattice corner, the centroid is the cell’s representative position. Cells, Vertices, and Spatial Identity is why the distinction is load-bearing.

Anchor and centroid of a cell

docs/_static/f4/f4_10_anchor_and_centroid.png

As a Shapely polygon

When you want to intersect, buffer or export, use cell_to_polygon polygon rather than the boundary ring:

poly = itacart.cell_to_polygon(cell)
poly.is_valid, poly.geom_type
(True, 'Polygon')

cell_to_polygon returns a valid Shapely polygon for the ordinary, border-absorbing, and polar cell families.

There is one important convention near the antimeridian. Cells that belong to an extension zone may use longitudes greater than 180° instead of wrapping immediately to the opposite side of the globe. Keeping those coordinates continuous prevents the polygon from being split or folded across the ±180° seam.

For example, a cell extending eastward from 179° may continue to 181° rather than being represented as 179° to −179°. In that continuous representation, Shapely sees the intended local polygon instead of a geometry spanning almost the entire longitude range.

See Extension Zones covers where those cells are.

The projected side

The same cell exists on the sinusoidal plane, and that is where the lattice is regular:

itacart.cell_to_sinusoidal(cell)
(14000000.0, -3740000.0)

Going the other way, sinusoidal_to_cell quantizes a projected position. The pair is the seam between the regular grid and the curved surface, and most of the package’s arithmetic happens on the plane side of it.

Vertex count is not constant

from itacart import boundary
[(c, boundary.cell_shape(c), len(itacart.cell_to_boundary(c, close=True)))
 for c in ("SE(1400/0374)", "NE(0000/0500)", "SE(1930/0196)")]
[('SE(1400/0374)', 'parallelogram', 5),
 ('NE(0000/0500)', 'triangle', 4),
 ('SE(1930/0196)', 'trapezoid', 5)]

A parallelogram and a trapezoid close with five positions; the meridian triangle closes with four. Code that assumes four corners will be wrong at the boundary, which is why cell_shape exists and why Polar & Border Cell Families is a page rather than a footnote.