Skip to main content

Build interactive 3D terrain HTML scenes from DEMs, rasters, vectors, and configurable map styles.

Project description

Piece of Cake

Piece of Cake builds interactive 3D terrain scenes from DEMs, rasters, vectors, and configurable geospatial styles.

It is deliberately focused on the 3D model. Give it a DEM and optional layers, then export a clickable HTML file or display it in a Jupyter/Colab notebook.

What It Does

  • Builds Plotly-based 3D terrain from a DEM.
  • Drapes custom raster layers on the terrain.
  • Draws vector overlays from GeoPackages, shapefiles, GeoJSON, or other GeoPandas-readable formats.
  • Lets users click the terrain to capture latitude, longitude, and elevation.
  • Exports standalone HTML.
  • Supports custom style profiles for unknown layers.
  • Helps inspect unknown raster/vector layers before styling them.

Install

From GitHub:

pip install "piece-of-cake-terrain[geo,places] @ git+https://github.com/WhatsThisClint/piece-of-cake.git@v0.1.1"

For the lightweight core:

pip install piece-of-cake-terrain

For geospatial raster/vector IO:

pip install "piece-of-cake-terrain[geo]"

For notebook display:

pip install "piece-of-cake-terrain[geo,notebook]"

For place-name lookup:

pip install "piece-of-cake-terrain[geo,places]"

For an isolated terminal command:

pipx install "git+https://github.com/WhatsThisClint/piece-of-cake.git@v0.1.1#egg=piece-of-cake-terrain[geo,places]"

With uv:

uv tool install git+https://github.com/WhatsThisClint/piece-of-cake.git@v0.1.1 --with rasterio --with geopandas --with pyproj --with shapely --with geopy

Quick Start

from piece_of_cake import TerrainScene

scene = TerrainScene.from_dem(
    "data/dem.tif",
    bounds=(76.1, 18.0, 76.4, 18.3),
    title="Dharashiv Terrain",
)

scene.add_raster(
    "Tree Canopy",
    "data/tree_canopy.tif",
    style={
        "type": "continuous",
        "label": "Tree canopy (%)",
        "cmap": "Greens",
        "opacity": 0.65,
    },
)

scene.to_html("dharashiv_terrain.html")

From the terminal:

piece-of-cake render --dem data/dem.tif --out dharashiv_terrain.html --title "Dharashiv Terrain"

You can also start from a place name when the optional places extra is installed:

scene = TerrainScene.from_place("Dharashiv, Maharashtra, India")
scene.add_dem(path="data/dem.tif")
scene.to_html("dharashiv_terrain.html")

Unknown Custom Layers

Piece of Cake does not assume what a custom layer means. Inspect it first:

from piece_of_cake import inspect_raster, inspect_vector

inspect_raster("custom_tree_canopy.tif")
inspect_vector("villages.gpkg")

For a GeoPackage with many columns, choose the column explicitly:

scene.add_vector(
    "SC/ST share",
    "villages.gpkg",
    column="sc_st_pct",
    label_column="village_name",
    hover_fields=["village_name", "population", "sc_st_pct"],
    style={
        "type": "continuous",
        "cmap": "Reds",
        "opacity": 0.55,
    },
)

DEM Sources

Version 0.1.0 supports local DEM files and custom provider hooks. Automatic DEM download is intentionally provider-based because DEM licensing, resolution, and reliability vary by country and source.

scene = TerrainScene.from_bbox(76.1, 18.0, 76.4, 18.3)
scene.add_dem(path="/content/drive/MyDrive/DEM/India.tif")

Or plug in your own provider:

scene.add_dem(provider=my_dem_provider)

See docs/providers.md.

Terminal Commands

piece-of-cake --help
piece-of-cake render --dem data/dem.tif --out terrain.html
piece-of-cake inspect-raster custom_tree_canopy.tif
piece-of-cake inspect-vector villages.gpkg

If Windows cannot find piece-of-cake because Python's Scripts folder is not on PATH, use:

python -m piece_of_cake --help

See docs/cli.md.

PyPI Publishing

Publishing is set up through GitHub Actions and PyPI Trusted Publishing. See docs/publishing.md for the one-time PyPI publisher fields and release workflow.

Citation

If you use Piece of Cake in research, reports, or public-facing tools, please cite it using the metadata in CITATION.cff.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piece_of_cake_terrain-0.1.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piece_of_cake_terrain-0.1.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file piece_of_cake_terrain-0.1.1.tar.gz.

File metadata

  • Download URL: piece_of_cake_terrain-0.1.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for piece_of_cake_terrain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b9b19987f5cc332ba594950f4b05e5626d920bdb0ce26eb1be5c068d25057815
MD5 4f61cb5b629003b31c6becf1c733b3b3
BLAKE2b-256 44a9063b29b7407e3093536d48c229cc4d522da57bf05beab2e67d3d1df16a91

See more details on using hashes here.

Provenance

The following attestation bundles were made for piece_of_cake_terrain-0.1.1.tar.gz:

Publisher: publish.yml on WhatsThisClint/piece-of-cake

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

File details

Details for the file piece_of_cake_terrain-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for piece_of_cake_terrain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ef502e3326c13280c44bb2dde1b9a5190181c727b54ba2b944eecf468c4f831
MD5 4da2cce17629709c0e5cc2b67df50a60
BLAKE2b-256 5f0948b6f93e3a2d5259c44e552284f67fc0bb0258a9d13c701a5fe4ddf46296

See more details on using hashes here.

Provenance

The following attestation bundles were made for piece_of_cake_terrain-0.1.1-py3-none-any.whl:

Publisher: publish.yml on WhatsThisClint/piece-of-cake

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