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

Frank Warmerdam warmerdam at pobox.com
Wed Aug 31 17:02:53 EDT 2011

On Wed, Aug 31, 2011 at 1:52 PM, Even Rouault
<even.rouault at mines-paris.org> 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
>> 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.


It also seems like a suitable job for ogrinfo.  It reports geometry as
WKT to the console, and you can use -sql, -where, -spat and -fid
mechanisms to select features of interest.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Software Developer

More information about the gdal-dev mailing list