Forum

Author Topic: exportOrthophotos only if complete polygon overlay  (Read 1233 times)

JLM

  • Newbie
  • *
  • Posts: 2
    • View Profile
exportOrthophotos only if complete polygon overlay
« on: December 04, 2020, 08:43:12 PM »

Hi,

Does anyone know a smart way to export only "complete" orthophotos for a given polygon?
As "incomplete" tif can be exported when one the orthophotos doesn't overlay completely the polygon (cf. example attached)
Or at least a way to sort "incomplete" and "complete" orthophotos.

I've looked a bit at the footprint macro option, but I guess the camera footprint might not be useful, as the orthophotos doesn't have the same area coverage
Same remark for the interesting post: https://www.agisoft.com/forum/index.php?topic=12559.msg56687#msg56687
(which could have been adapted to be the other way around)

Code: [Select]
#Export all orthophotos for each polygons in chunk
import Metashape
chunk = Metashape.app.document.chunk


output_dir = Metashape.app.getExistingDirectory()


for shape in chunk.shapes:
    if  shape.type != Metashape.Shape.Type.Polygon:
        continue
    shape.boundary_type = Metashape.Shape.BoundaryType.OuterBoundary
    path  = str(shape.label) + "_" + "{filename}" + "_" + "{filenum}.tif"
    chunk.exportOrthophotos(output_dir + "/" + path)
    shape.boundary_type = Metashape.Shape.BoundaryType.NoBoundary

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportOrthophotos only if complete polygon overlay
« Reply #1 on: December 05, 2020, 02:31:07 PM »
Hello JLM,

You can generate the footprint shapes with extended number of vertices (not only image corners, but also the vertices related to the image border. Then intersect "test"-shape with footprint for each camera and export the orthophoto only if test-shape is fully included to the footprint shape.
Best regards,
Alexey Pasumansky,
Agisoft LLC