geoq
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
|
}
# Feed that output into a map on geojson.io
| |
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:
gj
- GeoJSON subcommandsf
- Output geometry as GeoJSON featuregeom
- Output geometry as GeoJSON geometryfc
- Collect all input geometries into a GeoJSON Feature Collection
centroid
- Cet the centroid of a geometryfilter
- Spatial predicate filteringintersects
- Select features intersecting a given query geometrycontains
- Select features contained by a given query geometry
gh
- Geohash subcommandschildren
- Get children of a geohashcovering
- Output geohashes that "cover" a geometryneighbors
- Get neighbors of a Geohashpoint
- Output base 32 Geohash for a given Lat,Lon
json
- JSON -> GeoJSON coercionpoint
- Attempt to convert arbitrary JSON to a GeoJSON Point.
map
- Visualization with geojson.ioread
- Debugging / format validationwkt
- Output geometries as WKTwhereami
- Output IP geolocation-based current lat/lon as GeoJSONmeasure
- Measurement subcommandsdistance
- Measure distances between features
See the Manual for more examples and available commands.