Skip to content

Instantly share code, notes, and snippets.

@maning
Forked from perrygeo/ogrcat
Created June 12, 2017 09:05

Revisions

  1. @perrygeo perrygeo revised this gist Feb 7, 2016. No changes.
  2. @perrygeo perrygeo revised this gist Feb 7, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ogrcat
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ do
    if [ "$ECHO_FEATURES" == "true" ]; then

    # check for end of array
    if [ "$line" == "]" ]; then
    if [[ $line == ]* ]]; then
    exit 0
    fi

  3. @perrygeo perrygeo created this gist Feb 7, 2016.
    26 changes: 26 additions & 0 deletions ogrcat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/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