Skip to main content

OCGA: Procedural 3D Buildings for OpenStreetMap

Creating detailed 3D buildings in OSM by manually adding building:part's and moving nodes back and forth is tedious and slow.

OCGA (OSM Computer-Generated Architecture) is built on a key insight: much like music, architecture is often based on the repetition of common elements and patterns.

Because architecture is inherently rule-based, we can leverage a different approach: procedural generation. Instead of building models by hand, you define these architectural patterns using a simple .ocga language, and let the engine execute the repetitive work of generating the complex geometry for you.

To achieve this, we have developed a new, unique domain-specific language: OCGA. This project provides both the OCGA language specification and a simple command-line tool that interprets this new language, enabling rapid creation of detailed building models.

While certain ideas were adopted from ESRI's CityEngine, OCGA is not its clone, and many things are implemented differently.

Installation

Install the package from PyPI:

pip install ocga

Workflow

The intended cycle for using OCGA is as follows:

  1. Create an Outline: Start by saving a building's footprint/outline into its own .osm file.

  2. Define the Rules: Write a corresponding .ocga rules file tailored to that building's architecture. This is where you describe how to procedurally generate the model's parts.

  3. Generate the Model: Run the ocga command-line tool, providing it with your outline and rules files.

    ocga -i <path/to/your_building.osm> -r <path/to/your_rules.ocga> -o <path/to/generated_model.osm>
    
  4. Verify Before Uploading! Before you upload the data to OpenStreetMap, it is crucial to visually inspect the generated model.

    • Primary Method (JOSM): The easiest way is to open the generated .osm file in JOSM and use the UrbanEye3D plugin viewer.
    • Alternative Method: You can use osm2world to export the model to a .gltf file, which can then be opened in any standard 3D viewer (like the built-in Windows 3D Viewer or f3d on Linux).
  5. Upload to OpenStreetMap: Once you are satisfied, you can upload the data from JOSM. You may need to merge the layer containing the generated model with your main data layer before uploading.

Usage as a Library

While the primary use case for OCGA is the command-line tool, its core engine can be imported and used directly in your own Python projects, as permitted by the MIT license.

The main entry point function is ocga_process2, which can be imported from the top-level package. Its function is analogous to the CLI tool:

from ocga import ocga_process2

input_file = "path/to/building.osm"
rules_file = "path/to/rules.ocga"
output_file = "path/to/generated.osm"

# The other arguments are optional
ocga_process2(input_file, output_file, rules_file)

Other functions from the engine modules (e.g., from ocga.ocga_engine) can also be imported, but their APIs are not guaranteed to be stable and may change. Use them at your own risk.

Language and Examples

  • For a complete guide to the syntax and operations, see the OCGA Language Reference.
  • A collection of sample .osm and .ocga files can be found in the docs/ocga_samples directory.
  • The example.bat and example.sh scripts in the root directory demonstrate how to run the tool on these samples.

Release files for ocga-cli 0.1.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 ocga-cli 0.1.0
File Size Uploaded
ocga_cli-0.1.0.tar.gz 203.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ocga-cli 0.1.0
File Interpreter ABI Platform
ocga_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 265.9 kB

Release files / ocga_cli-0.1.0.tar.gz

Download URL ocga_cli-0.1.0.tar.gz
Size 203.0 kB
Tags Source
SHA-256 checksum
How to use checksums
79c4967516225bdfb8395483dc88de245997a1303bb64a0beaaadaf5b2e090b6
BLAKE2b-256 checksum
How to use checksums
863251bb689b558c7e96067f487bce7c480fbf256048b6651d73744fb68398cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 17, 2026.

Transparency log

Release files / ocga_cli-0.1.0-py3-none-any.whl

Download URL ocga_cli-0.1.0-py3-none-any.whl
Size 62.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9201c961411280a3328f4cd205e057ebcd0918095c5d127ddc76df68645b5b4a
BLAKE2b-256 checksum
How to use checksums
cb83ebb873a65d84e6ecaf471e910c608200f344c182b9ecbd7020c9e63aad8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

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