itacart.cells.cell_to_centroid
- itacart.cells.cell_to_centroid(cell)[source]
Geodetic centroid of a cell, which is its representative position.
Every route that answers a cell with one point answers with this one.
itacart.cell_to_latlng()returns it in(lat, lng)order,itacart.engine.ITACaRT.cell_to_centroid()returns it for one cell,itacart.geometry.cells_to_geometry()rebuilds vertices on it, anditacart.engine.describe()declares it. The centroid lies within the cell in every family, which a vertex cannot.Computed on the projection plane, where the cell’s edges are straight and its centroid is the area-weighted one, then inverted back to geodetic. The plane is equal-area, so the weighting the centroid depends on is the one the plane preserves.
Averaging the four geodetic vertices instead would be wrong: it weights by longitude, which the projection compresses by
cos(phi), and it breaks outright for any cell spanning the antemeridian.All three shapes are handled. For a parallelogram and for a triangle the area centroid coincides with the mean of the vertices; for a clipped trapezoid it does not, and the mean would sit off centre.