-
-
Save jaredrada/c86088066314aa5e4cc6cde929437a2b to your computer and use it in GitHub Desktop.
ogrcat: make line-delimited geojson features to stdout from any ogr vector datasource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # ogrcat | |
| # produces line-delimited geojson features | |
| # Like `fio cat` but uses ogr2ogr under the hood | |
| ECHO_FEATURES="" | |
| ogr2ogr -f GeoJSON /vsistdout/ "$@" | while read line | |
| do | |
| if [ "$line" == "\"features\": [" ]; then | |
| ECHO_FEATURES="true" | |
| else | |
| if [ "$ECHO_FEATURES" == "true" ]; then | |
| # check for end of array | |
| if [[ $line == ]* ]]; then | |
| exit 0 | |
| fi | |
| # strip trailing comma | |
| echo $line | sed "s/,$//" | |
| fi | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment