3

I am following this question with the first answer Dissolve/aggregate polygons with ogr2ogr or gpc? where I am trying to dissolve my shapefile down to 1 row by the geometry field

ogr2ogr C:\Users\name\Desktop\output.shp C:\Users\name\Desktop\All_constraints_v5.shp -dialect sqlite -sql "SELECT ST_Union(geometry) FROM input"

ERROR 1: In ExecuteSQL(): sqlite3_prepare(SELECT ST_Union(geometry) FROM input):
 no such table: input

right so then I did

C:\Program Files\GDAL>ogrinfo -so C:\Users\rizagha\Desktop\All_constraints_v5.shp
INFO: Open of `C:\Users\rizagha\Desktop\All_constraints_v5.shp'
      using driver `ESRI Shapefile' successful.
1: All_constraints_v5 (Polygon)

So my question is

  1. "SELECT ST_Union(geometry) FROM input" does input need to be my shp full path variable? what is the exact syntax

  2. I cannot find out what the geometry column is called.

I ran this:

C:\Program Files\GDAL>ogrinfo -geomfield -fields=YES C:\Users\rizagha\Desktop\All_constraints_v5.shp
INFO: Open of `C:\Users\rizagha\Desktop\All_constraints_v5.shp'
      using driver `ESRI Shapefile' successful.
1: All_constraints_v5 (Polygon)

but it doesn't tell me what column name the geom is

  • 5
    As ogrinfo shows, your layer name is All_constraints_v5 and that is what you will use for FROM. Geometry field is "geometry" for the SQLite dialect. – user30184 Dec 20 '17 at 16:03
  • ahh gotcha okay that worked – ziggy Dec 20 '17 at 16:08
  • @user30184 put it as answer so I can close this question out – ziggy Jan 2 '18 at 14:06
3

As ogrinfo shows, the layer name is All_constraints_v5 and therefore the righ command is

ogr2ogr C:\Users\name\Desktop\output.shp C:\Users\name\Desktop\All_constraints_v5.shp -dialect sqlite -sql "SELECT ST_Union(geometry) FROM All_constraints_v5"
| improve this answer | |

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.