[gdal-dev] Extract Linestrings from GeometryCollections with ogr2gor

Even Rouault even.rouault at spatialys.com
Mon Mar 16 14:28:03 PDT 2015


Stefan,

you could try the -explodecollections of ogr2ogr.

Even

> Hi
>
> I have some contour lines which I clip with ogr2ogr's -clipsrc options. As
> a result and in very rare cases I get some GeometryCollections which cannot
> be stored in a  shapefile.
>
> So I'm clipping to a GeoPackage and tried to extract the LinesStrings from
> the GeometryCollections with the following command:
>
> ogr2ogr -dialect INDIRECT_SQLITE -sql 'SELECT ID, elev,
> (ST_Dump(geom)).geom as geom FROM linestring WHERE geometrytype =
> \'LINESTRING'\' clipped_dumped.shp clipped.gpkg
>
> ST_Dump seems to be unknown (as SQlite does not support arrays I guess) so
> is ST_CollectionExtract(geom,2).
>
> Is there a way to extract LineStrings from GeometryCollections. Probably
> already avoiding them when clipping the original geometry?
>
> best regards
> Stefan
>


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list