czml3
From the official CZML Guide:
CZML is a JSON format for describing a time-dynamic graphical scene, primarily for display in a web browser running Cesium. It describes lines, points, billboards, models, and other graphical primitives, and specifies how they change with time.
czml3 aims to make the process of writing CZML files in Python easy by:
- Type checking properties
- Coercion of data to their required format
- Forbidding unrecognised properties
- Creating minimal CZML files
- Fast JSON serialization
Installation
You can install czml3 using pip:
pip install czml3
or conda:
conda install czml3 --channel conda-forge
Examples
Creating a document
A CZML document is a list of packets, which have several properties. Recreating the blue box from Cesium sandcastle's CZML Box:
from czml3 import (
Box,
BoxDimensions,
Color,
Document,
Material,
Packet,
Position,
SolidColorMaterial,
)
packet_box = Packet(
id="my_id",
position=Position(cartographicDegrees=[-114.0, 40.0, 300000.0]),
box=Box(
dimensions=BoxDimensions(cartesian=[400000.0, 300000.0, 500000.0]),
material=Material(
solidColor=SolidColorMaterial(color=Color(rgba=[0, 0, 255, 255]))
),
),
)
doc = Document(packets=[packet_box])
print(doc)
Output
[
{
"id": "document",
"name": "document",
"version": "1.0"
},
{
"id": "my_id",
"position": {
"cartographicDegrees": [
-114.0,
40.0,
300000.0
]
},
"box": {
"dimensions": {
"cartesian": [
400000.0,
300000.0,
500000.0
]
},
"material": {
"solidColor": {
"color": {
"rgba": [
0,
0,
255,
255
]
}
}
}
}
}
]
The document packet
Document adds the required preamble packet (id="document") when you don't supply one. To name the document or set its clock, pass your own preamble packet first:
from czml3 import CZML_VERSION, Document, Packet
doc = Document(
packets=[
Packet(id="document", name="My scene", version=CZML_VERSION),
packet_box,
]
)
Imports
The most common classes can be imported from czml3 directly; everything else lives in czml3.properties, czml3.types and czml3.enums.
Data coercion
czml3 uses pydantic for all classes, so it is able to coerce data to their right type.
Plain lists are converted to the matching CZML value type, so BoxDimensions(cartesian=[...]) is equivalent to BoxDimensions(cartesian=Cartesian3Value(values=[...])).
Arrays are coerced too. For example, the following creates a Position property of doubles using a numpy array of integer type:
import numpy as np
from czml3.properties import Position
print(Position(cartographicDegrees=np.array([-114, 40, 300000], dtype=int)))
{
"cartographicDegrees": [
-114.0,
40.0,
300000.0
]
}
Saving and loading
doc.save("scene.czml")
doc = Document.load("scene.czml")
Viewing a document
In Jupyter, displaying a Document renders it in an interactive Cesium viewer.
Outside notebooks, write the same viewer as a standalone page:
doc.save_html("scene.html")
ion_token=uses Cesium ion imagery and terrain.cesium_version=chooses the CesiumJS release.
Browsers block Cesium's web workers on pages opened straight from disk (file://), so serve the file over HTTP and open http://localhost:8000/scene.html:
python -m http.server
Contributing
You want to contribute? Awesome! There are lots of CZML properties and validations that we still did not implement, which can be found here.
All ideas welcome!
Metadata
Release files for czml3 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| czml3-4.0.0.tar.gz | 63.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| czml3-4.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 103.4 kB
Release files / czml3-4.0.0.tar.gz
| Download URL | czml3-4.0.0.tar.gz |
|---|---|
| Size | 63.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b24866c5f30c9217445759c2cd080e99970324b97d1ab0dec4f8845e9907ebd
|
|
BLAKE2b-256 checksum How to use checksums |
94f8d79c1ead1355dfdbeb0e22c75c98d5d05e35678cbb2f7f66d78e8d30d235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / czml3-4.0.0-py3-none-any.whl
| Download URL | czml3-4.0.0-py3-none-any.whl |
|---|---|
| Size | 40.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c37c63010a65c5d348b061d3b1106c1d817d90d14662fa7af525ce32c8b5bbf
|
|
BLAKE2b-256 checksum How to use checksums |
edb84ff3aa5a09b5e847e885e4272254a3a1102285853d6975d3d4346d066c09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency log