4

It seems that support for streaming input is weak in ogr2ogr. For example, why can I do this:

curl "http://data.usgin.org/arizona/wfs?service=WFS&version=1.1.0&
request=GetFeature&typeName=azgs:activefaults&maxFeatures=10" | 
ogr2ogr -f "KML" /vsistdout/ /vsistdin/

... but I can't do this:

curl "http://data.usgin.org/arizona/wfs?service=WFS&version=1.1.0&
request=GetFeature&typeName=azgs:activefaults&maxFeatures=10&
outputformat=application/json" | ogr2ogr -f "KML" /vsistdout/ /vsistdin/

The first request uses the "WFS" driver for the source layer, and the second request uses the "GeoJSON" driver for the source layer. The first one works fine, but the second gives me:

ERROR 1: GeoJSON parsing error: unexpected end of data (at offset 6000)
ERROR 4: Failed to read GeoJSON data
FAILURE:
Unable to open datasource `/vsistdin/' with the following drivers.
Ryan Clark
  • 301
  • 2
  • 8

2 Answers2

1

If you have this problem with earlier gdal versions or other formats just add information about format which is on stdin e.g.

curl "http://data.usgin.org/arizona/wfs?service=WFS&version=1.1.0&
request=GetFeature&typeName=azgs:activefaults&maxFeatures=10&
outputformat=application/json" | ogr2ogr -f "KML" /vsistdout/ GeoJSON:/vsistdin/
user19291
  • 191
  • 7
0

What version of GDAL are you using? This seems to be fixed as of gdal-2.2.0, as this command works seems to work:

$ ogr2ogr --version
GDAL 2.2.0, released 2017/04/28

$ curl "http://data.usgin.org/arizona/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=azgs:activefaults&maxFeatures=10&outputformat=application/json" | ogr2ogr -f "KML" /vsistdout/ /vsistdin/
Pete
  • 10,310
  • 7
  • 53
  • 59