More

GDAL -SQL or -where options

GDAL -SQL or -where options


ogr2ogr -overwrite -t_srs EPSG:3978 -f "ESRI Shapefile" -sql "SELECT * FROM 'Layer Name' WHERE FIELD_NAME = 'A CLASS'" dst.shp src.shp

help me out here - looking to 1) reproject a shape and 2) select only "A CLASS" from field named "FIELD_NAME" 3) and save it to src.shp

my output is ERROR 1: Type mismatch or improper type of arguments to = operator.

I've also tried ogr2ogr -overwrite -t_srs EPSG:3978 -f "ESRI Shapefile" -where "FIELD_NAME = 'A CLASS'" dst.shp src.shp resulting in: ERROR 1: SQL Expression Parsing Error: syntax error FAILURE: SetAttributeFilter( WHERE FIELD_NAME = 'A CLASSS') on layer 'LAYER NAME' failed.

and

ogr2ogr -overwrite -t_srs EPSG:3978 -f "ESRI Shapefile" -where "FIELD_NAME LIKE 'A CLA%'" dst.shp src.shp with the las which only produces one results, where 10,000+ records satisfy the query.


update

ogr2ogr -overwrite -t_srs EPSG:3978 -f "ESRI Shapefile" -dialect SQLite -sql "SELECT * FROM 'Layer Name' WHERE FIELD_NAME = 'A CLASS'" dst.shp src.shp

yields ERROR 1: Type mismatch or improper type of arguments to = operator. ERROR 1: In ExecuteSQL(): sqlite3_step(SELECT * FROM 'Layer Name' WHERE GIVEN_CLASS = 'Class A'): SQL logic error or missing database

one step closer though!


well the winner is to not use the = sign. this works for anyone looking…

ogr2ogr -overwrite -t_srs EPSG:3978 -f "ESRI Shapefile" -dialect SQLite -where "GIVEN_CLASS LIKE 'CLAS% A" dst src

indicating dialect + using -where + Like operator.


Watch the video: Install GDAL on Windows. burdGIS