Agisoft Metashape
Agisoft Metashape => General => Topic started by: photo_man on June 26, 2019, 01:37:10 PM
-
Hi, I am drawing a polygon on my DEM and I want it to be a perfect rectangle. But, my selections are imperfect and the edges are slanted.
Is there any way to force the shape to be a rectangle?
Thanks!
-
draw it on cad and import to your project
-
Thanks JMR, but I'm looking for a way to do this in PhotoScan. I don't want to add another program to my workflow.
Any other ideas?
-
Hello photo_man,
If you are drawing the shapes in Ortho view mode, holding SHIFT key would help to draw the straight lines.
Alternative way could be a custom Python script. For example, you draw the point shapes that define the opposite corners of your rectangular area, select them and run the script which creates a new polygonal shape automatically.
The following script should work in such way, providing that coordinate system is Local Coordinates or some projected system (would not work correctly for WGS84):
import Metashape
chunk = Metashape.app.document.chunk
shapes = [shape for shape in chunk.shapes if (shape.type == Metashape.Shape.Point and shape.selected)]
if len(shapes) != 2:
print("Select exactly two point shapes!")
Metashape.app.messageBox("Select exactly two point shapes!")
else:
new_shape = chunk.shapes.addShape()
new_shape.type = Metashape.Shape.Polygon
new_shape.has_z = False
new_shape.vertices = [shapes[0].vertices[0], Metashape.Vector([shapes[0].vertices[0].x, shapes[1].vertices[0].y]), shapes[1].vertices[0], Metashape.Vector([shapes[1].vertices[0].x, shapes[0].vertices[0].y])]
print("New rectangular shape created.")
Metashape.app.messageBox("New rectangular shape created.")
-
Perfect, thank you!