Forum

Author Topic: Use Raster Transform and Palette  (Read 3467 times)

thiago.br@live.com

  • Newbie
  • *
  • Posts: 1
    • View Profile
Use Raster Transform and Palette
« on: November 27, 2020, 03:55:07 AM »
Hello!

I'm looking forward to set a raster a formula on Raster Calculator and changing the palettes, after generating DEM and an Orthomosaic via Python API.

I have found this example below, but it seems deprecated now. What are the functions to set a formula for raster calculator, apply and change the palettes?

Thanks for now! :)

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)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Use Raster Transform and Palette
« Reply #1 on: November 27, 2020, 03:15:52 PM »
Hello Thiago,

Please try the following:
Code: [Select]
chunk.raster_transform.formula = ['(B5 - B3) / (B5 + B3) ', 'B6 * 0.04 - 273']
chunk.raster_transform.calibrateRange()
chunk.raster_transform.enabled = True
chunk.raster_transform.palette = {-1.0: (5, 24, 82),
 0.0: (255, 255, 255),
 0.10000000149011612: (191, 165, 127),
 0.30000001192092896: (135, 184, 0),
 0.6000000238418579: (0, 115, 0),
 1.0: (0, 0, 0)}
chunk.exportRaster(path, source_data = Metashape.OrthomosaicData, image_format = Metashape.ImageFormatTIFF, raster_transform = Metashape.RasterTransformValue)

The example on image compression parameters is given here:
https://www.agisoft.com/forum/index.php?topic=11687.msg52464#msg52464
Best regards,
Alexey Pasumansky,
Agisoft LLC