4

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

ziggy
  • 4,515
  • 3
  • 37
  • 83

1 Answers1

4

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"
user30184
  • 65,331
  • 4
  • 65
  • 118