Skip to main content

czml3

pypi conda Python codecov pypi-downloads conda-downloads workflow-status Documentation Status

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)

Source distribution for czml3 4.0.0
File Size Uploaded
czml3-4.0.0.tar.gz 63.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for czml3 4.0.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.3.6

2 release files

2.3.5

2 release files

2.3.4

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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