Skip to main content

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

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

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

Uploaded Python 3Windows x86-64

cityjson_lib-0.9.0-py3-none-manylinux_2_28_x86_64.whl (5.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

cityjson_lib-0.9.0-py3-none-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

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

Hashes for cityjson_lib-0.9.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 cb00356e8d7b5886a88b2857f57400026cf4e15b77f7fac3eeaaf7619e36688e
MD5 28db1a4813d514dece8a2e337eb7eca8
BLAKE2b-256 2bfd491afc97176b89e956502c1576de585a4ab53cd5df9a065817b4427755d2

See more details on using hashes here.

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

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.9.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.9.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f3f264c32105482740739b1b095368a130e028b4962c7cb581779d2847a167a6
MD5 a60e8e251e7357fbd74f2b62fe2b86a8
BLAKE2b-256 deb76622e29a4cdedc690e696b7b0c53f5683d8d5fab9d8ccaa36fda6489f934

See more details on using hashes here.

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

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.9.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cityjson_lib-0.9.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1a87e581b7cfb358369dc68c8c5a8cbad0f79ffcb9bcf53482079855334433b
MD5 3638be7a25622fe9bd7b5cf184f23068
BLAKE2b-256 236ce57304836d4c3a4902451b277ff0878b4fdd21f25d53e92709f1075f1d78

See more details on using hashes here.

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

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page