cligj - Click parameters for GeoJSON CLIs

0.7.2 · active · verified Thu Apr 09

cligj provides a collection of reusable Click parameter and option decorators specifically designed for building command-line interfaces that interact with GeoJSON data. It simplifies handling GeoJSON input/output, feature processing, and related geospatial concerns within Click applications. The current version is 0.7.2, and it maintains a stable release cadence typical for a mature utility library.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `cligj.features_in_info` to create a Click command that reads GeoJSON features from standard input, adds a new property indicating the feature's index in the input stream, and writes the modified features as a GeoJSON sequence to standard output. It's a common pattern for processing streamable GeoJSON data.

import click
import json
import sys
from cligj import features_in_info

@click.command()
@features_in_info
def cli(src_features):
    """
    Reads GeoJSON features from stdin, adds a feature index to properties,
    and writes the modified features to stdout as a GeoJSON sequence.

    Usage example:
    echo '{"type":"Feature","properties":{},"geometry":null}' | python your_script.py
    """
    for f, i in src_features:
        f['properties']['f_idx'] = i['f_idx']
        click.echo(json.dumps(f))

if __name__ == '__main__':
    cli()

view raw JSON →