Forum

Author Topic: exportRaster DEM Export fails with NullException  (Read 1617 times)

salmon

  • Newbie
  • *
  • Posts: 7
    • View Profile
exportRaster DEM Export fails with NullException
« on: January 13, 2021, 02:55:50 PM »
Hello folks,
i'm using a script to export DEM from a number of projects. It worked flawlessly for a few projects and in one project it produces an Exception. I'm running Metashape on 1.7.0 11736.
What could be the problem? Export works from the GUI.

Code: [Select]

utm_NRW = Metashape.CoordinateSystem("EPSG::25832")
projection = Metashape.OrthoProjection()
projection.crs = utm_NRW

chunk.exportRaster(
        source_data=Metashape.ElevationData,
        path="G:/THS-data/data-processing/1-6/out/data/dsm.tif",
        projection=projection,
        image_format=Metashape.ImageFormatTIFF,
        resolution_x=0.01,
        resolution_y=0.01,
        white_background=False,
        clip_to_boundary=False,
        save_alpha=False,
        save_scheme=True)


Log:

ExportRaster: clip_to_boundary = off, image_format = TIFF, path = G:/THS-data/data-processing/1-6/out/data/dsm.tif, projection = ETRS89 / UTM zone 32N, resolution_x = 0.01, resolution_y = 0.01, save_alpha =
off, save_scheme = on, source_data = Elevation, white_background = off
Traceback (most recent call last):
  File "export-data.py", line 95, in <module>
    exportDataFromProject(project_file.as_posix())
  File "export-data.py", line 86, in exportDataFromProject
    exportDataRaster(chunk, export_location,
  File "export-data.py", line 48, in exportDataRaster
    chunk.exportRaster(
Exception: Null elevation


DEM Details
Size   14,475 x 18,681
Coordinate system   WGS 84 (EPSG::4326)
Reconstruction parameters   
Source data   Dense cloud
Interpolation   Enabled
Processing time   1 minutes 50 seconds
Memory usage   365.99 MB
Software version   1.6.1.10009
File size   381.68 MB

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportRaster DEM Export fails with NullException
« Reply #1 on: January 13, 2021, 03:49:41 PM »
Hello salmon,

Is the elevation model active in the chunk? Are you able to get any output for chunk.elevation call?
Best regards,
Alexey Pasumansky,
Agisoft LLC

salmon

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: exportRaster DEM Export fails with NullException
« Reply #2 on: January 13, 2021, 08:57:43 PM »
Hello Alexey,
thanks you pointed the right direction!

The DEM was not set as Default therefore not active when the project is opened although it is the only DEM in the project. For that project i managed fix the issue by opening the GUI and selecting the DEM as Default in the Context Menu.

Is there an option to do this programatically?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportRaster DEM Export fails with NullException
« Reply #3 on: January 13, 2021, 08:59:44 PM »
Hello salmon,

You can set the first elevation in the chunk as a default one with the following line:
Code: [Select]
chunk.elevation = chunk.elevations[0]
Best regards,
Alexey Pasumansky,
Agisoft LLC

salmon

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: exportRaster DEM Export fails with NullException
« Reply #4 on: January 14, 2021, 03:39:56 PM »
Ok, thanks again!