[Gdal-dev] ogr2ogr -where "attribute=value" no spaces allowed?

Frank Warmerdam warmerdam at pobox.com
Mon Oct 25 15:37:52 EDT 2004


Dylan Beaudette wrote:
> Hi,
> 
> I am using the ogr2ogr command to extract features from a shapefile, based on 
> a specific value for an attribute in the DBF by specifying a -where argument:
> 
> ogr2ogr -f "ESRI Shapefile" -where "DESCRIPT=Blue Oak Woodland" 
> Blue_Oak_Woodland.shp ../vegetation_polygon.shp
> 
> however, it seems like any spaces in the "DESCRIPT=Blue Oak Woodland" argument 
> causes the following error;
> 
> ERROR 1: Syntax error, 2 extra tokens
> 
> ...which seems to match the number of spaces in the "DESCRIPT=Blue Oak 
> Woodland" argument..
> 
> is there any way to get around this problem?

Dylan,

You need to quote the value you are comparing the DESCRIPT field to, much as
you would have to if you were doing this in SQL.

eg.
ogr2ogr -f "ESRI Shapefile" -where 'DESCRIPT="Blue Oak Woodland"' \
            Blue_Oak_Woodland.shp ../vegetation_polygon.shp

Good luck,

-- 
---------------------------------------+--------------------------------------
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 Programmer for Rent




More information about the Gdal-dev mailing list