Agisoft Metashape

Agisoft Metashape => Bug Reports => Topic started by: Damian on February 25, 2021, 10:58:13 AM

Title: Invalid shape - polygonal
Post by: Damian on February 25, 2021, 10:58:13 AM

For every project I create a kml with several polygonal shapes. Each shape has a description - map section's number. With Metashape 1.6. it was not a problem to import it and use for exporting shapes with proper file name. Now with 1.7. when I import a kml (which by the way in QGIS is imported as polygon), I cannot use it for export - just as if it was a poyline, not polygon. I cannot use it as boundary or measure the area.

In attachement two examples of KML.

I do not want to downgrade to 1.6. Is there any way you could make it work?

Best wishes
Title: Re: Invalid shape - polygonal
Post by: vbarty on March 04, 2021, 01:35:22 AM
Hi Damian,

I've tried to look into the issue and downloaded your kml files and imported them to Metashape. It seems that these two files have a different structure - one is imported as one layer with multiple objects and the second is imported as multiple layers (each containing one object) - but I was still able to import them and set boundary type on each polygon without any problems.

I'm not sure what you mean by using them for exporting shapes with the proper file name. Do you want to export each polygon as a separate file? Or you want to use each polygon as a boundary for your ortho/dem/point cloud export? 
Title: Re: Invalid shape - polygonal
Post by: Damian on March 04, 2021, 11:52:35 AM

They might have different structure, but the point is that in 1.6 Metashape I am able to set them as boundary, while in 1.7 Metashape this option is greyed out. What is more I cannot calculate the area which makes me think that they are being imported as polyline, not polygon.

I use them to export ortho and dem in parts, but now I cannot do it. KMLs are prepared and exported from QGIS.

What version of Metashape do you use? I downgraded to 1.6.6. and the problem dissapeared.  However, that is not the solution I expected to work out.
Title: Re: Invalid shape - polygonal
Post by: Alexey Pasumansky on March 14, 2021, 02:14:19 PM
Hello Damian,

Which 1.7 version you are using?

Can you please check, if the issue is resolved in 1.7.2 pre-release:                   - Windows 64 bit                          - macOS           - Linux 64 bit
Title: Re: Invalid shape - polygonal
Post by: Corensia on April 15, 2021, 11:26:09 AM
Dear Alexey,

We're also seeing a similar situation with DXF files.

We would draw a polygon to measure the volume of a pile and then export the shape in DXF form to use for future measurements. When the shape is imported into Metashape again, it is considered as a polyline and cannot be used to measure the volume even though it is opened as a polygon in other programs. This bug was first seen in 1.7.1 and continues in 1.7.2. The last documented case of it working fine was in 1.6.4.

Hope that helps.

Warm regards,
Title: Re: Invalid shape - polygonal
Post by: Alexey Pasumansky on April 15, 2021, 08:21:57 PM
Hello David,

Thank you for reporting. We'll check it in the latest version and see, if it could be fixed quickly.
Title: Re: Invalid shape - polygonal
Post by: Matt on February 09, 2022, 06:24:42 AM
Hi Alexey,

I am still having trouble with importing a shape to set as the boundary for Orthomosaic clipping.

I have attached a kml that enables you to set the type as Boundary in version 1.5 but will not give that option in version 1.8

Can you advise a workaround other than loading the project in 1.5 to do it.

Many Thanks


Title: Re: Invalid shape - polygonal
Post by: Paulo on February 09, 2022, 08:50:24 AM
Hello Matt,

your kml contains a MultiGeometry feature containing one polygon and so imports as a MultiPolygon type shape (instead of simple polygon) into Metashape 1.8. That is probably the reason you cannot set the boundary from context menu....see attachment. But if your feature is defined as a simple polygon in kml, then its boundary will be able to be set in Metashape...

A workaround dealing with multigeometry feature kml can be done by code snippet.... for example the following code would transform all MultiPolygon features present in a chunk to simple Polygons who can then be selected and boundary type set:
Code: [Select]
import Metashape as ps
chunk =
for s in [s for s in chunk.shapes if  s.geometry.type == ps.Geometry.Type.MultiPolygonType]: #transform all MultiPolygon into Polygons
    for i,g in enumerate(s.geometry.geometries):
        shape = chunk.shapes.addShape()
        shape.label = s.label + '_Polygon'  + str(i+1) =
        shape.attributes = s.attributes
        shape.geometry = g
Title: Re: Invalid shape - polygonal
Post by: Matt on February 11, 2022, 01:54:54 AM
Thanks Paulo,

That seems to have done the trick.
Weird that the shapes work with the old version though.
My thought is that Metashape is importing the shapes as multipolygon in error.

Title: Re: Invalid shape - polygonal
Post by: Paulo on February 11, 2022, 02:15:26 AM
No problem, Matt,

since v. 1.8 and removal of class Shape.Type which had
Shape type (deprecated) in [Point, Polyline, Polygon]
and replacement with class Geometry.Type (from v.1.7) which has
Geometry type in [PointType, LineStringType, PolygonType, MultiPointType, MultiLineStringType, MultiPolygonType,
, MultiGeometry feature types can now be recognized and so a MultiGeometry feature with one or more polygons will be imported as a MultiPolygon whereas previously (before 1.7) it was imported as one or more individual polygons...