[gdal-dev] split multipolygons?

Frank Warmerdam warmerdam at pobox.com
Mon Nov 26 12:54:11 EST 2007


Milo van der Linden wrote:
> Hello list,
> 
> I have a table in mapinfo format that contains different geometry types. 
> some are errors and when I filter out the errors, multipolygon and 
> polygon remain.
> 
> I try to use ogr2ogr  with -nlt to only get polygons. This doesn't work 
> the way I want it. When I open the resulting table in OpenJUMP, there 
> are still multipolygons in my table which prevent me from saving changes 
> I make with OpenJump.

Milo,

The -nlt switch sets the type of a layer, but doesn't - in itself -
alter what geometries get written to the layer.

> What I would like to know is if it is possible to split multipolygons to 
> polygons with regards to maintaining the attributes. Can this be done?   
> kind regards,

With GDAL/OGR 1.4+ you should be able to do something like:

   ogr2ogr out.shp in.shp -where "OGR_GEOMETRY = 'POLYGON'" in

I'm not sure if I have the quoting right.

Basically, OGR_GEOMETRY is a special field that will contain
the OGC WKT name for the geometry per:

   http://trac.osgeo.org/gdal/wiki/rfc6_sqlgeom

It can be used in attribute filters.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list