Forum

Author Topic: Orthomosaic export after raster calculation formula  (Read 9077 times)

dustin.waller

  • Newbie
  • *
  • Posts: 2
    • View Profile
Orthomosaic export after raster calculation formula
« on: October 04, 2017, 08:34:07 PM »
I am very new to Photoscan and I am trying to understand the Python API parameters for exporting an orthomosaic by using a raster formula. I am currently able to process and export the basic orthomosaic with this line.

chunk.exportOrthomosaic(outputs+"\\ortho.tif", write_world=True, tiff_big=True)

The formula I want to use is (B1+B2+B3)*2/B2

I am aware of the class PhotoScan.RasterTransform class but I am not sure how to utilize it in my code using my formula. Can anyone help this "rookie?"

Thanks.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15320
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #1 on: October 04, 2017, 08:50:05 PM »
Hello dustin.waller,

At first you need to define the formula for the chunk and then use raster_transform argument in the export function:

Code: [Select]
chunk.raster_transform.formula = ["(B1+B2+B3)*2/B2"]
chunk.raster_transform.calibrateRange()
chunk.raster_transform.enabled = True
chunk.exportOrthomosaic(outputs+"\\ortho.tif", image_format = PhotoScan.ImageFormatTIFF, raster_transform = PhotoScan.RasterTransformValue, write_world=True, tiff_big=True)
Best regards,
Alexey Pasumansky,
Agisoft LLC

dustin.waller

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #2 on: October 04, 2017, 09:12:53 PM »
That did the trick. I greatly appreciate the quick reply. That means a lot to us when we are testing out a software...

Corensia

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #3 on: April 23, 2024, 09:30:55 AM »
I was using this thread as a reference for my task and I am running into problems. I'm trying to export orthomosaics using raster transform 'B4' values using a script  but when I compare it to the orthomosaic  exported from the GUI, I get different values and different tif file sizes as well. What could be the problem? I've posted the script below along with the export settings that I used in the GUI. I'm currently using Metashape 2.0.1.

Code: [Select]
import Metashape

app = Metashape.app
doc = app.document

chunk = doc.chunk

proj = Metashape.OrthoProjection()
proj.crs = Metashape.CoordinateSystem("EPSG::4326")

chunk.raster_transform.formula = ["B4"]
chunk.raster_transform.calibrateRange()
chunk.raster_transform.enabled = True

exportPath = "[i]path[/i]"

compression = Metashape.ImageCompression()
compression.tiff_compression = Metashape.ImageCompression.TiffCompressionLZW
compression.tiff_big = True

chunk.exportRaster(path=exportPath, source_data = Metashape.OrthomosaicData, raster_transform = Metashape.RasterTransformValue, image_format = Metashape.ImageFormat.ImageFormatTIFF, image_compression = compression, save_world = True, save_alpha = False, global_profile = True, white_background = False)
« Last Edit: April 23, 2024, 11:58:12 AM by Corensia »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15320
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #4 on: April 23, 2024, 02:24:27 PM »
Hello Corensia,

Can you please duplicate the chunk with only orthomosaic, remove the orthophotos from that duplicated chunk, save the project and send the following files from the chunk's folder in project.files directory to support@agisoft.com: chunk.zip, frame.zip and contents of orthomosaic subdirectory.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15320
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #5 on: April 27, 2024, 06:21:22 PM »
Hello Corensia,

Thank you for sharing the data.

I am trying to reproduce your result, but am getting similar min/max values in QGIS. Is it possible that you have any boundary shapes in the original project? If so, you should then set clip_to_boundary=False in the export command, because by default exportRaster has clipping to boundary enabled.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Corensia

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #6 on: April 30, 2024, 03:34:56 AM »
I used the script you send and it worked great! I think it may have been enabling 'big tiff' that caused the differences but I'm not sure either.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15320
    • View Profile
Re: Orthomosaic export after raster calculation formula
« Reply #7 on: April 30, 2024, 05:19:24 PM »
Hello Corensia,

Good to hear, that the problem is resolved on your end as well. My assumption was that the difference has been caused by the boundary shapes that are applied to the API export by default, unless disabled by the corresponding parameter.
Best regards,
Alexey Pasumansky,
Agisoft LLC