itacart.interop.from_geojson

itacart.interop.from_geojson(obj, resolution, containment='center')[source]

Fill every geometry of a GeoJSON object into a compositional index.

This is the filling path, and it is lossy by construction: the cells that cover a shape are not the shape. It is named apart from recover_from_geojson() on purpose, because the two answer different questions and sharing a name with a switching argument would hide which one a caller got.

There is no crs argument. RFC 7946 section 4 fixes GeoJSON to WGS84 and records that alternative coordinate reference systems were removed from the specification, so accepting one here would be accepting something the format does not have.

A geometry of dimension zero is quantized, not filled. A Point or a MultiPoint has no area for a fill to cover, and each of its points has exactly one owning cell, which itacart.cells.geo_to_cell() answers. A Point becomes that cell; a MultiPoint becomes the region its owners compose. containment is validated but decides nothing here, since all three predicates relate a cell to an area. Lines and polygons go to itacart.geometry.polyfill(), which refuses a line under center or contains by saying that it has no area.

Parameters:
  • obj (dict[str, Any]) – A GeoJSON Feature, FeatureCollection or bare geometry.

  • resolution (int) – Target resolution level.

  • containment (str, default: "center") – Predicate passed through to itacart.geometry.polyfill(); not consulted for a geometry of dimension zero.

Return type:

list[str]

Returns:

One compositional index per input geometry, in file order. A point inside the cell that holds a pole at resolution 10 is answered, at resolutions 11 and 12, with the spelling itacart.cells.geo_to_cell() gives it, which can name no cell: a known limitation, stated in itacart.cells.

Raises:
  • ValueError – If containment is not one of the three predicates.

  • GeometryError – If a geometry of dimension zero is empty, or if a fill keeps no cell. And from resolution 11, if a line or a polygon reaches the cell that holds a pole at resolution 10, whose children cannot be enumerated: a known limitation, stated in itacart.hierarchy.

  • UnsupportedGeometryTypeError – If a geometry is of a type the reader cannot draw. The geometry library raises its own error for that, which is outside this package’s hierarchy, so one except ITACaRTError around a pipeline would not have caught it.