Forum

Author Topic: Auto Export Orthophoto by index (sheet ) name ?  (Read 3225 times)

Uygar

  • Newbie
  • *
  • Posts: 30
    • View Profile
Auto Export Orthophoto by index (sheet ) name ?
« on: November 30, 2020, 10:04:12 AM »
Hi.

I have sheets by dxf format . How can ı export orthophotos by index ( sheet ) names with automatic .

I have 600 sheets, it takes a long time to export them one by one.

Thank you.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #1 on: November 30, 2020, 11:13:53 AM »
Hello Uygar,

Do you have multiple DXFs - one per desired export area, or single DXF file contains all the polygons with proper labels for export purposes?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Uygar

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #2 on: November 30, 2020, 12:44:25 PM »
File is attached.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #3 on: November 30, 2020, 07:05:54 PM »
Hello Uygar,

The provided DXF doesn't contain Metashape supported elements (POLYLINE type) therefore you should re-save the DXF in the external application, for example, Global Mapper.

After that, if Import Shapes operation works properly and you can see the polygons properly loaded to the chunk with the orthomosaic the following script can be used to export the orthomosaic tiled according to the available polygonal shapes:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk

output_dir = Metashape.app.getExistingDirectory("Specify the output folder:")

for shape in chunk.shapes:
    if  shape.type != Metashape.Shape.Type.Polygon:
        continue
    shape.boundary_type = Metashape.Shape.BoundaryType.OuterBoundary
    path  = "ortho_" + str(shape.key) + "_" + shape.label + ".tif"
    chunk.exportRaster(output_dir + "/" + path, source_data = Metashape.DataSource.OrthomosaicData)
    shape.boundary_type = Metashape.Shape.BoundaryType.NoBoundary

The code assumes that the shape labels should be used for the orthomosaic tiles exporting. If the desired labels are stored in some shape attributes, the output path should be adjusted accordingly.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Uygar

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #4 on: December 04, 2020, 11:49:23 AM »
You are my hero ,  Thank you so much !

And how can i export DEM , Pointcloud, Google KMZ and 3D mesh model like this :))

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #5 on: December 04, 2020, 04:12:01 PM »
Hello Uygar,

Please check the updated script. If should export DEM (in GeoTIFF), orthomosaic (in GeoTIFF), dense point cloud (in LAS), mesh model (in OBJ).
Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk
output_dir = Metashape.app.getExistingDirectory("Specify the output folder:")
output_crs = Metashape.app.getCoordinateSystem("Specify output Coordinate System:", chuunk.crs)
if not output_crs:
output_crs = chunk.crs
proj = Metashape.OrthoProjection()
proj.crs = output_crs

for shape in chunk.shapes:
if  shape.type != Metashape.Shape.Type.Polygon:
continue
shape.boundary_type = Metashape.Shape.BoundaryType.NoBoundary

for shape in chunk.shapes:
if  shape.type != Metashape.Shape.Type.Polygon:
continue
shape.boundary_type = Metashape.Shape.BoundaryType.OuterBoundary

if chunk.orthomosaic: #export ortho
path  = "ortho_" + str(shape.key) + "_" + shape.label + ".tif"
chunk.exportRaster(output_dir + "/" + path, source_data = Metashape.DataSource.OrthomosaicData, projection  = proj)

if chunk.elevation: #export DEM
path  = "DEM_" + str(shape.key) + "_" + shape.label + ".tif"
chunk.exportRaster(output_dir + "/" + path, source_data = Metashape.DataSource.ElevationData, projection  = proj)

if chunk.dense_cloud: #export points
path  = "points_" + str(shape.key) + "_" + shape.label + ".las"
chunk.exportPoints(output_dir + "/" + path, source_data = Metashape.DenseCloudData, format = Metashape.PointsFormatLAS, crs = output_crs)

if chunk.model: #export mesh
path  = "mesh_" + str(shape.key) + "_" + shape.label + ".obj"
chunk.exportModel(output_dir + "/" + path, format = Metashape.ModelFormatOBJ, crs = output_crs)

shape.boundary_type = Metashape.Shape.BoundaryType.NoBoundary
print("Finished")


What kind of output in KMZ format do you need to export?

Best regards,
Alexey Pasumansky,
Agisoft LLC

Uygar

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #6 on: December 07, 2020, 07:14:47 PM »
How can ı export transparent orto so this problem happen in junction areas .

And standart kmz orthophoto export ...
« Last Edit: December 07, 2020, 07:17:07 PM by Uygar »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #7 on: December 07, 2020, 09:59:59 PM »
Hello Uygar, 

You need to add "save_alpha = True" argument to exportRaster command for orthomosaic export.

For KMZ orthomosaic export add:

Code: [Select]
if chunk.orthomosaic: #export ortho
path  = "ortho_" + str(shape.key) + "_" + shape.label + ".kmz"
chunk.exportRaster(output_dir + "/" + path, format =  format = Metashape.RasterFormatKMZ, source_data = Metashape.DataSource.OrthomosaicData, projection  = proj)

Best regards,
Alexey Pasumansky,
Agisoft LLC

Uygar

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #8 on: December 09, 2020, 07:51:27 PM »
Everything works fine , thank you.

Uygar

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #9 on: December 22, 2020, 05:41:43 PM »
Hi,

How can ı export obj files with local coordinates ? I can not find in pyton manual .

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Auto Export Orthophoto by index (sheet ) name ?
« Reply #10 on: December 23, 2020, 11:32:34 AM »
Hello Uygar,

Please check, if the following approach solves the task of mesh export in local coordinates:

Code: [Select]
crs_local = Metashape.CoordinateSystem('LOCAL_CS["Local Coordinates (m)",LOCAL_DATUM["Local Datum",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]')
chunk.exportModel(output_dir + "/" + path, format = Metashape.ModelFormatOBJ, crs = crs_local)
Best regards,
Alexey Pasumansky,
Agisoft LLC