ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

You should check the geometry type before trying to extract the boundaries.

With this you should cover all cases. Let's consider that you object is called multi.

if multi.geom_type == 'MultiPolygon':
        for p in multi:
            if p.geom_type == 'MultiPolygon':
                print("MultiPolygon in MultiPolygon!!!")
                for sp in p:
                    xd,yd = sp.exterior.coords.xy
            elif p.geom_type in ['Point', 'LineString']:
                xd,yd = p.xy
            elif p.geom_type == 'MultiLineString':
                for ea in p:
                    xd,yd = ea.xy
            elif p.geom_type == 'Polygon':
                xd,yd = p.exterior.coords.xy

Then check this link to fill the points list And this one to fill the details of each point

Hope this helps