Skip to main content

cityjson-lib

Python bindings for the cityjson-lib Rust crate — a higher-level read/write facade for CityJSON 2.0.

The distribution name is cityjson-lib; the import name is cityjson_lib. Under the hood the package ships a prebuilt native library (built from the Rust C-ABI core) and a thin ctypes wrapper — no Rust toolchain or compiler is required on the user side.

Install

pip install cityjson-lib

Prebuilt wheels are published for:

  • Linux x86_64 (manylinux)
  • macOS x86_64 and arm64
  • Windows AMD64

Python 3.11, 3.12, and 3.13 are supported.

Quick start

from cityjson_lib import CityModel, probe_bytes

payload = open("model.city.json", "rb").read()

probe = probe_bytes(payload)
print(probe.root_kind, probe.version)

model = CityModel.parse_document_bytes(payload)
summary = model.summary()
print(summary.model_type, summary.cityobject_count)

For an end-to-end authoring example that exercises the full public Python API, see examples/fake_complete.py.

Selection and merge workflows

CityModel.subset_cityobjects(...) remains the simple helper for extracting whole CityObjects by id. For workflows that need relationship expansion, geometry-level selection, or set operations, use ModelSelection and then materialize the result with CityModel.extract_selection(...).

from cityjson_lib import CityModel, GeometrySelectionSpec, ModelSelection, merge_models

model = CityModel.parse_document_bytes(open("model.city.json", "rb").read())

selection = ModelSelection.select_cityobjects_by_id(model, ["building-part-1"])
with_relatives = selection.include_relatives(model)
extracted = model.extract_selection(with_relatives)

first_geometry = ModelSelection.select_geometries_by_cityobject_id_and_index(
    model,
    [GeometrySelectionSpec("building-1", 0)],
)
second_geometry = ModelSelection.select_geometries_by_cityobject_id_and_index(
    model,
    [("building-1", 1)],
)

combined = first_geometry.union(second_geometry)
overlap = first_geometry.intersection(second_geometry)
assert not overlap.is_empty()  # The CityObject remains, without geometry.

geometry_extract = model.extract_selection(combined)
merged = merge_models([extracted, geometry_extract])

Selection handles own native resources. They can be used as context managers or closed explicitly when deterministic release is useful in long-running processes.

Links

License

Dual-licensed under MIT or Apache-2.0, at your option.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cityjson_lib-0.11.0-py3-none-win_amd64.whl (4.0 MB view details)

Uploaded Python 3Windows x86-64

cityjson_lib-0.11.0-py3-none-manylinux_2_28_x86_64.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

cityjson_lib-0.11.0-py3-none-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file cityjson_lib-0.11.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.11.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b1eeb3f830c2bb01d3630f1b15df3a7c6d9c08e008c43ad370f18cb1f2686b59
MD5 f2e86240851f96eedf0100bd0e3de99c
BLAKE2b-256 9bb754f1bc0e0f24bdb745f6af94a6e7a00da55b1b1f5828f196c4647f778617

See more details on using hashes here.

Provenance

The following attestation bundles were made for cityjson_lib-0.11.0-py3-none-win_amd64.whl:

Publisher: release.yml on 3DGI/cityjson-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cityjson_lib-0.11.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.11.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f2c017e553c3b4399937951af39fc4d0c533371697f0a37d2dbaa87d89825404
MD5 fc735ce09ed1b2a429efc3178f7b0e5a
BLAKE2b-256 93c266ef569f4e22fda3e561344c61cd884ccecb1c9859fe622961e88a62aed9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cityjson_lib-0.11.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on 3DGI/cityjson-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cityjson_lib-0.11.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.11.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70415d1fb7b3e1c21817a981d964da522c61a0f0f9a5582f7e0c7db769773b92
MD5 69bfd00dd081ba7279c9092fd56539ba
BLAKE2b-256 ed59a1eff442a3d32c5ce45b9ec133760da14bfedef1407473da60355af60ea2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cityjson_lib-0.11.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on 3DGI/cityjson-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.11.0 This release

3 files

0.10.0

3 files

0.9.0

3 files

0.6.1

2 files

0.6.0

2 files

0.5.3

2 files

0.5.0

2 files

0.4.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page