On Thu, Feb 24, 2011 at 2:43 PM, Mohammed Rashad <span dir="ltr">&lt;<a href="mailto:mohammedrashadkm@gmail.com" target="_blank">mohammedrashadkm@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


How to convert mutipolygon to polygon<div><br></div><div>my code</div><div>string geometry = &quot;MULTIPOLYGON (((76.742484035494002 9.949536084104899,76.783465713734998 9.8207365239198,76.818592866512006 9.8773302700617,76.842010968363994 9.931972507716001,76.742484035494002 9.949536084104899)))&quot;;</div>




<div><br></div><div><div>    char *geom = (char *) geometry.c_str();</div><div><br></div><div> OGRGeometry *OLGeometry = NULL;</div><div><br></div><div><br>

</div><div> OGRGeometryFactory::createFromWkt( &amp;geom, NULL, &amp;OLGeometry );</div><div><br></div><div>the OLGeometry is multipolygon I need it as polygon as given below.</div><div><br></div><div>Note: both are not equal</div>




<div><br></div><div>POLYGON ((76.334618761574006 10.378867951388999,76.338521778548994 10.419849629630001,76.404873067129998 10.349595324074,76.371697422840001 10.271534984568,76.334618761574006 10.378867951388999))</div>




<div><br></div><div><br></div></div></blockquote><div><br></div><div>This is Python code, but you can easily convert it to C:</div><div><br></div><div>multipoly_geom = ogr.CreateGeometryFromWkt(&#39;MULTIPOLYGON (((76.742484035494002 9.949536084104899,76.783465713734998 9.8207365239198,76.818592866512006 9.8773302700617,76.842010968363994 9.931972507716001,76.742484035494002 9.949536084104899)))&#39;)</div>


<div><div>for geom_part in multipoly_geom:</div><div>    print geom_part.ExportToWkt()</div></div><div><br></div><div>POLYGON ((76.742484035494002 9.949536084104899,76.783465713734998 9.8207365239198,76.818592866512006 9.8773302700617,76.842010968363994 9.931972507716001,76.742484035494002 9.949536084104899))</div>


<div><br></div><div>also give a look at this previous discussion:</div><div><a href="http://www.mail-archive.com/gdal-dev@lists.osgeo.org/msg09285.html" target="_blank">http://www.mail-archive.com/gdal-dev@lists.osgeo.org/msg09285.html</a></div>


<div><br></div><div>best regards</div><div>P</div></div><br>-- <br>Paolo Corti<br>Geospatial software developer<br>web: <a href="http://www.paolocorti.net" target="_blank">http://www.paolocorti.net</a><br>
twitter: @paolo_corti<br>