I am trying to convert SQL Shapes to ESRI Shapefiles using the instructions in this blog post from a few years back and OSGeo4W.
I'm most of the way there, but I'm losing a shape here and there on account of some of them being GeometryCollection shape types. Is it possible to convert GeometryCollections to Polygons on the fly and get all of these shapes out in the same shapefile at once? Or should I just extract them separately and match them up later?
Not sure it's necessary, but this is the command I'm using in the OSGeo4W Shell
ogr2ogr -f "ESRI Shapefile" "C:\FolderName\AllShapes.shp" "MSSQL:server=MyServer;database=ShapeDatabase;table=.dbo.Shapes; trusted_connection=yes;" -sql "Select ShapeID, ShapeTypeID as ShapeType, ShapeData From .dbo.Shapes Where ShapeData.STGeometryType() In ('Polygon','Multipolygon','geometrycollection')"
That command works if I dump out 'geometrycollection', but, as I mentioned, I'm then missing a bunch of shapes.