Python bindings for cityjson-lib
Project description
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
- Rust workspace and docs: https://github.com/3DGI/cityjson
- CityJSON specification: https://www.cityjson.org
- Issues: https://github.com/3DGI/cityjson/issues
License
Dual-licensed under MIT or Apache-2.0, at your option.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cityjson_lib-0.9.0-py3-none-win_amd64.whl.
File metadata
- Download URL: cityjson_lib-0.9.0-py3-none-win_amd64.whl
- Upload date:
- Size: 4.0 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb00356e8d7b5886a88b2857f57400026cf4e15b77f7fac3eeaaf7619e36688e
|
|
| MD5 |
28db1a4813d514dece8a2e337eb7eca8
|
|
| BLAKE2b-256 |
2bfd491afc97176b89e956502c1576de585a4ab53cd5df9a065817b4427755d2
|
Provenance
The following attestation bundles were made for cityjson_lib-0.9.0-py3-none-win_amd64.whl:
Publisher:
release.yml on 3DGI/cityjson-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cityjson_lib-0.9.0-py3-none-win_amd64.whl -
Subject digest:
cb00356e8d7b5886a88b2857f57400026cf4e15b77f7fac3eeaaf7619e36688e - Sigstore transparency entry: 1437401415
- Sigstore integration time:
-
Permalink:
3DGI/cityjson-rs@b07512f78240984da437121cf210c0839d1ba52f -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/3DGI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b07512f78240984da437121cf210c0839d1ba52f -
Trigger Event:
push
-
Statement type:
File details
Details for the file cityjson_lib-0.9.0-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cityjson_lib-0.9.0-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3f264c32105482740739b1b095368a130e028b4962c7cb581779d2847a167a6
|
|
| MD5 |
a60e8e251e7357fbd74f2b62fe2b86a8
|
|
| BLAKE2b-256 |
deb76622e29a4cdedc690e696b7b0c53f5683d8d5fab9d8ccaa36fda6489f934
|
Provenance
The following attestation bundles were made for cityjson_lib-0.9.0-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on 3DGI/cityjson-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cityjson_lib-0.9.0-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
f3f264c32105482740739b1b095368a130e028b4962c7cb581779d2847a167a6 - Sigstore transparency entry: 1437401407
- Sigstore integration time:
-
Permalink:
3DGI/cityjson-rs@b07512f78240984da437121cf210c0839d1ba52f -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/3DGI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b07512f78240984da437121cf210c0839d1ba52f -
Trigger Event:
push
-
Statement type:
File details
Details for the file cityjson_lib-0.9.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: cityjson_lib-0.9.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.3 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1a87e581b7cfb358369dc68c8c5a8cbad0f79ffcb9bcf53482079855334433b
|
|
| MD5 |
3638be7a25622fe9bd7b5cf184f23068
|
|
| BLAKE2b-256 |
236ce57304836d4c3a4902451b277ff0878b4fdd21f25d53e92709f1075f1d78
|
Provenance
The following attestation bundles were made for cityjson_lib-0.9.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on 3DGI/cityjson-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cityjson_lib-0.9.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
e1a87e581b7cfb358369dc68c8c5a8cbad0f79ffcb9bcf53482079855334433b - Sigstore transparency entry: 1437401399
- Sigstore integration time:
-
Permalink:
3DGI/cityjson-rs@b07512f78240984da437121cf210c0839d1ba52f -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/3DGI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b07512f78240984da437121cf210c0839d1ba52f -
Trigger Event:
push
-
Statement type: