0

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!

  • Try the first query by adding -dialect=SQLite. – user30184 Aug 25 '15 at 4:11
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.