Forum

Author Topic: Set Shape as Boundary Type "Outer"  (Read 3659 times)

ATaylor

  • Newbie
  • *
  • Posts: 5
    • View Profile
Set Shape as Boundary Type "Outer"
« on: October 26, 2023, 06:16:23 AM »
I have a workflow for photogrammetry data where the user places all image folders and kml boundaries into the project folder and the scrpit below is intended to automatically import multiple folders to one chunk, prompt the user for the coordinate system, then import a kml or kmz that should be used as an outer boundary for clipping exported data later on.   I am having a problem with getting the script to define the kml shape as an outer boundary and I get the following error:

Error importing KML/KMZ file: module 'Metashape' has no attribute 'BoundaryType'

I've attached the whole script but the function in question is:


def import_kml_kmz(chunk, file_path):
    try:
        # Set boundary type to "Outer"
        chunk.boundary_type = Metashape.BoundaryType.OuterBoundary
       
        # Import KML/KMZ
        chunk.importKML(file_path)
        print(f"KML/KMZ file '{os.path.basename(file_path)}' imported successfully.")
    except Exception as e:
        print(f"Error importing KML/KMZ file: {e}")

Does anyone know if this functionality is supported?

Diogo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Set Shape as Boundary Type "Outer"
« Reply #1 on: October 27, 2023, 01:38:12 PM »
The function you've described
Code: [Select]
chunk.importKML doesn't exist. Use
Code: [Select]
chunk.importShapes(path=file_path, boundary_type=Metashape.BoundaryType.OuterBoundary) instead.