20 releases

0.0.20 Nov 22, 2021
0.0.18 Jul 8, 2021
0.0.17 Feb 27, 2021
0.0.16 Dec 15, 2020
0.0.4 Jul 17, 2018

#315 in Command line utilities

Download history 12/week @ 2021-10-03 23/week @ 2021-10-10 3/week @ 2021-10-17 1/week @ 2021-10-24 14/week @ 2021-10-31 24/week @ 2021-11-07 7/week @ 2021-11-14 24/week @ 2021-11-21 22/week @ 2021-11-28 22/week @ 2021-12-05 5/week @ 2021-12-12 15/week @ 2021-12-19 11/week @ 2021-12-26 20/week @ 2022-01-02 14/week @ 2022-01-09 4/week @ 2022-01-16

51 downloads per month

MIT license

105KB
2.5K SLoC

geoq

Build Status crates.io

Geoq is a command-line tool for working with geospatial data.

It combines common GIS serialization formats with utilities for manipulating and visualizing data on a map.

For example:

# Print the geometry and the set of level 2 geohashes which covers the given geometry
$ echo '{"type":"Polygon","coordinates":[[[-34,38],[-37,32],[-23,33],[-34,38]]]}' | geoq gh covering 2 -o
{"type":"Polygon","coordinates":[[[30,10],[40,40],[20,40],[10,20],[30,10]]]}
eq
en
em
ej

# Feed that output into a map on geojson.io
$ echo '{"type":"Polygon","coordinates":[[[-34,38],[-37,32],[-23,33],[-34,38]]]}' | geoq gh covering 2 -o | geoq map

See the Manual for more examples and available commands.

Install

Currently installation is done through crates.io, the Rust package repository.

If you have Rust installed, simply:

cargo install geoq

To install Rust and the Cargo toolchain:

curl https://sh.rustup.rs -sSf | sh

You'll also need to add Cargo's bin directory to your path:

# e.g. in your ~/.bash_profile or other shell profile
export PATH="$HOME/.cargo/bin:$PATH"

Updating an Existing Installation

To pull and install a newer version from crates.io, run:

cargo install geoq --force

Supported Input Formats

Geoq will detect the following GIS input formats automatically:

  • Comma-separated Lat/Lon: 34.0,-118.0
  • Geohashes (base 32): 9q5
  • WKT: POINT (-118.0, 34.0)
  • GeoJSON: {"type": "Point", "coordinates": [-118.0, 34.0]}

One Feature Per Line, One Line Per Feature

Geoq processes text inputs on a per-line basis, and it expects inputs not to stretch across multiple lines.

This sometimes causes problems, especially with GeoJSON, because many JSON processing tools like to output pretty-printed JSON in a multi-line format.

One way to fix this problem with pretty-printed GeoJSON is to use the jq tool:

echo '{
    "type": "Point",
    "coordinates": [30, 10]
}
' | jq -c . | geoq map

Commands

See the built-in command help using geoq --help or geoq <subcommand> --help for more detailed information on these:

  • bbox - Give bounding boxes for geometries, or for a stream of geometries collectively
  • centroid - Cet the centroid of a geometry
  • filter - Spatial predicate filtering
    • intersects - Select features intersecting a given query geometry
    • contains - Select features contained by a given query geometry
  • gh - Geohash subcommands
    • children - Get children of a geohash
    • covering - Output geohashes that "cover" a geometry
    • neighbors - Get neighbors of a Geohash
    • point - Output base 32 Geohash for a given Lat,Lon
  • gj - GeoJSON subcommands
    • f - Output geometry as GeoJSON feature
    • geom - Output geometry as GeoJSON geometry
    • fc - Collect all input geometries into a GeoJSON Feature Collection
  • json - JSON -> GeoJSON coercion
    • munge - Attempt to convert arbitrary JSON to a GeoJSON Feature.
  • map - Visualization with geojson.io
  • measure - Measurement subcommands
    • distance - Measure distances between features
    • coord-count - Give the number of vertices in geometries
  • read - Debugging / format validation
  • shp - Convert shapefiles to GeoJSON
  • simplify - Simplify geometries, either with fixed threshold or iteratively toward target coord-count
  • whereami - Output IP geolocation-based current lat/lon as GeoJSON
  • wkt - Output geometries as WKT

See the Manual for more examples and available commands.

Development

Running Tests

cargo test

Building / Releasing

cargo publish
git tag release/<VERSION>
git push origin release/<VERSION>

Dependencies

~21MB
~473K SLoC