[gdal-dev] ogr2ogr - output WKT to console?

Elijah Robison elijah at villagis.com
Wed Aug 31 18:19:52 EDT 2011


Rad. :)

Thanks, Even.

It took me a few minutes to realize that -f "CSV" still applied --- but 
now I'm catching on. I presume the following statement is true:

The special "/vsistdout/" file path will output ogr2ogr results directly 
to the console, provided the output type is a text-based format for 
which OGR supports dataset creation.

I wonder about that text-based caveat, but I wasn't able to push a 
shapefile to the console (and didn't expect to), yet I /was /able to 
push several pure text formats to the console.

For those keeping score, and for posterity within the nabble list cache, 
the following redactions of my initial ogr2ogr script send their result 
set directly to the console:

ogr2ogr -f "CSV" "/vsistdout/" 
"C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from 
feb16_polygons where objectid= 2126" -lco "GEOMETRY=AS_WKT" -lco 
"LINEFORMAT=CRLF" -lco "SEPARATOR=SEMICOLON"

ogr2ogr -f "GML" "/vsistdout/" 
"C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from 
feb16_polygons where objectid= 2126"

ogr2ogr -f "KML" "/vsistdout/" 
"C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from 
feb16_polygons where objectid= 2126"

ogr2ogr -f "GeoJSON" "/vsistdout/" 
"C:\xData\CountyUpdate\GeoFix\feb16_polygons.shp" -sql "select * from 
feb16_polygons where objectid= 2126"

Many thanks to everyone who offered feedback.

Best, Elijah


Even Rouault wrote:
> Le mercredi 31 août 2011 22:44:55, Elijah Robison a écrit :
>   
>> Hi Devs,
>>
>> When troubleshooting geodata integrity issues, we sometimes use ogr2ogr
>> to push WKT expressions to a .csv file using a script like I show below.
>> It uses an ogr sql statement to grab a single feature from a raw
>> shapefile data source, then it saves the output to a CSV:
>>
>> ogr2ogr -f "CSV" "C:\xData\CountyData\Shps\OriginalParcelCSV"
>> "C:\xData\CountyData\Shps\parcel_polygons.shp" -sql "select * from
>> parcel_polygons where id= 9080" -lco "GEOMETRY=AS_WKT" -lco
>> "LINEFORMAT=CRLF" -lco "SEPARATOR=SEMICOLON"
>>
>> As our needs in this situation are very transient, I'm curious if it is
>> possible to output the WKT directly to the console?
>>     
>
> Yes, as a output filename, you can use the special name /vsistdout/ (you need 
> the trailing slash) . You likely need GDAL 1.8 or later for it to work.
>
>   
>> Very Best,
>>
>> Elijah Robison
>> elijah at villagis.com
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>     
>
>   


More information about the gdal-dev mailing list