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 overlap.is_empty()

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.10.0-py3-none-win_amd64.whl (4.0 MB view details)

Uploaded Python 3Windows x86-64

cityjson_lib-0.10.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.10.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.10.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.10.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 40039f929809c5823c3015f7057962d97155863f7eaaa078405bb9f1162ceec6
MD5 d798aad01f0ab931a21a90e62c7f92a9
BLAKE2b-256 f038404a6369ce86e75e836a49010191c26eb1d2c189ab3dd736728d9aec53c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cityjson_lib-0.10.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.10.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.10.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e6f79c291b2eaf0c9143d04d21bbcd1215f17d73913ed9401e9b5f211ce06c2
MD5 da4b36bf26b04f7143d96d55190513a4
BLAKE2b-256 5d61db954334882c1cb27ec92b6ad400c4da2b05dde59618264475d5a08e8dc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cityjson_lib-0.10.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.10.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.10.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6e903336f829276042c4840298436e7d6b87a52851023b9cbf5f3f634ccf24f
MD5 868a9e3709e61c06cdd745cf20b846ec
BLAKE2b-256 40f3cf2c9c13aa55be5bff268385738ef1d26b09ede4d5fd765b47a0f85b8455

See more details on using hashes here.

Provenance

The following attestation bundles were made for cityjson_lib-0.10.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

0.11.0

3 files

This release

0.10.0 This release

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