[gdal-dev] ogr2ogr -nlt PROMOTE_TO_MULTI (use case: converting shapefiles to PostGIS)

Even Rouault even.rouault at mines-paris.org
Wed Sep 26 14:37:39 PDT 2012


Hi,

Have you ever been frustrated about shapefiles mixing polygons/multipolygons 
(or linestrings/multilinestrings) in the same layer and issues when converting 
them to PostGIS ?

I was, until a few minutes ago, where I've just added in GDAL trunk "-nlt 
PROMOTE_TO_MULTI" as an accepted option of ogr2ogr.

The effect of this option is that when a layer is of type Polygon, it will be 
converted in the target format as MultiPolygon, and any Polygon feature in the 
layer will be promoted to MultiPolygon (existing MultiPolygons will be left 
untouched). The same for LineString / MultiLineString. Other geometry types 
will be left untouched (i.e. Point will not be converted to MultiPoint (they 
are identified as separate types in shapefiles).

This option works for any source or target datasource, so the shapefile -> 
PostGIS is just one particular (but typical) use case.

Previously you could use -nlt MULTIPOLYGON or -nlt MULTILINESTRING but that 
couldn't be used when doing a mass conversion of shapefiles that mixed different 
types of geometries.

Best tregards,

Even


More information about the gdal-dev mailing list