Skip to content

topojson.utils

coordinates

coordinates(arcs, tp_arcs, geom_type)

Return GeoJSON coordinates for the sequence(s) of arcs.

The arcs parameter may be a sequence of ints, each the index of a coordinate sequence within tp_arcs within the entire topology describing a line string, a sequence of such sequences, describing a polygon, or a sequence of polygon arcs.

geometry

geometry(obj, tp_arcs, transform=None)

Converts a topology object to a geometry object.

The topology object is a dict with 'type' and 'arcs' items.

prettyjson

prettyjson(obj, indent=2, maxlinelength=80)

Renders JSON content with indentation and line splits/concatenations to fit maxlinelength. Only dicts, lists and basic types are supported

indentitems

indentitems(items, indent, level)

Recursively traverses the list of json lines, adds indentation based on the current depth

serialize_as_geodataframe

serialize_as_geodataframe(fc, crs=None)

Convert a topology dictionary or string into a GeoDataFrame.

Parameters:

Name Type Description Default
fc (dict, str)

a complete object representing a GeoJSON file

required
crs (str, dict)

coordinate reference system to set on the resulting frame. Default is None.

None

Returns:

Type Description
GeoDataFrame

topojson object parsed as GeoDataFrame

serialize_as_polars

serialize_as_polars(fc, crs=None)

Convert a GeoJSON FeatureCollection into a Polars DataFrame: the id, the properties as columns and the geometry as WKB in the column geometry, as polars-st stores it. With a CRS that has an EPSG code, the WKB is EWKB with this code as SRID.

Parameters:

Name Type Description Default
fc dict

a complete object representing a GeoJSON file

required
crs (str, int, CRS)

coordinate reference system of the geometries, such as "EPSG:4326". Default is None.

None

Returns:

Type Description
DataFrame

topojson object parsed as Polars DataFrame