#geospatial #geography #spatial-index #gis #system #h3 #json-format

bin+lib h3o-cli

A CLI app that exposes most of the h3o API for scripting

11 releases

0.2.6 Nov 28, 2024
0.2.4 Apr 15, 2024
0.2.3 Mar 25, 2024
0.2.1 Oct 26, 2023
0.1.1 Jan 15, 2023

#98 in Geospatial

Download history 25/week @ 2024-09-22 170/week @ 2024-09-29 19/week @ 2024-10-06 8/week @ 2024-10-13 1/week @ 2024-10-20 4/week @ 2024-11-03 1/week @ 2024-11-17 137/week @ 2024-11-24 16/week @ 2024-12-01

154 downloads per month

BSD-3-Clause

73KB
2K SLoC

h3o-cli — A CLI app exposing the h3o API for scripting

Crates.io Docs.rs CI Status Coverage License

How to install

Pre-compiled binaries

You can download a pre-compiled executable for Linux, MacOS and Windows operating systems from the release page, then you should copy that executable to a location from your $PATH env.

Build Manually

If you prefer to build h3o-cli manually, or a pre-compiled executable is not provided for your platform, then you can build h3o-cli from the source:

Usage

Each subcommand comes with its own help through -h/--help.

There are two classes of output format for the commands:

  • text format (text and JSON)
  • geo format (KML and GeoJSON)

Most of the commands can either take a single input from the CLI options or a list of input from stdin.

Plain text output can be directly used as input for others, allowing command pipelines.

For geo output:

  • cellToLatLng returns the center (Point) of each index
  • cellToBoundary returns the outline (LineString) of each index
  • cellToPolygon returns the shape (Polygon) of contiguous indexes.

Examples

Prints information (coordinates, area, …) about on given cell:

h3o-cli cellInfo -i 844c001ffffffff

Decodes an index into its components:

h3o-cli indexDecode -i 21b1fb4644920fff --pretty

Creates a GeoJSON file containing the cell center points of all of the resolution 9 hexagons covering Uber HQ and the surrounding region of San Francisco.

h3o-cli cellToChildren --parent 86283082fffffff --resolution 9 \
    | h3o-cli cellToLatLng -f geojson > uber9pts.geojson

Generates the set of indexes that cover Paris at resolution 11 and save the compacted result in cells.txt.

h3o-cli geomToCells -r 11 -f geojson < paris.geojson | h3o-cli compact > cells.txt

Prints the indexes from the 2-ring around 89283082ed7ffff.

h3o-cli gridDisk -o 89283082ed7ffff -r 2

At resolution 7, prints the grid path that goes through a bunch of French cities and return the resulting KML.

h3o-cli latLngToCell -r 7 < cities-center.txt \
    | h3o-cli gridPath \
    | h3o-cli cellToBoundary -f kml

Load the shape of a city, compute the cell coverage at resolution 11 and save the compressed result in city.cht:

h3o-cli geomToCells -r 11 < city.geojson \
    | h3o-cli compact \
    | h3o-cli compress > city.cht

License

BSD 3-Clause

Dependencies

~14MB
~210K SLoC