Forum

Author Topic: How do you set the boundaries?  (Read 6851 times)

Natsumi

  • Newbie
  • *
  • Posts: 12
    • View Profile
How do you set the boundaries?
« on: August 26, 2021, 12:17:19 PM »
Hello everyone,

I need to set the boundaries when exporting the orthomosaic.
I want to enable "Seutp boundaries" and set the coordinates.
How do I need to set it?
I couldn't find it in the reference.

Thank you in advance.

Paulo

  • Hero Member
  • *****
  • Posts: 1529
    • View Profile
Re: How do you set the boundaries?
« Reply #1 on: August 26, 2021, 11:24:31 PM »
Hello Natsumi,

please look at exportRaster() method in API reference maual and parameter region.....
Quote
exportRaster(path='', format=RasterFormatTiles, image_format=ImageFormatNone,
raster_transform=RasterTransformNone[, projection ], region = BB , resolution=0,
resolution_x=0, resolution_y=0, block_width=10000, block_height=10000,
split_in_blocks=False, width=0, height=0[, world_transform], nodata_value=-32767,
save_kml=False, save_world=False, save_scheme=False, save_alpha=True,
image_description=''[, image_compression ], network_links=True, min_zoom_level=-1,
max_zoom_level=-1, white_background=True, clip_to_boundary=True, title='Orthomosaic',
description='Generated by Agisoft Metashape', source_data=OrthomosaicData,
north_up=True, tile_width=256, tile_height=256[, progress ])
region = BB sets the bounding box for your OrthoMosaic export...
where BB = Metashape.BBox()
BB.min is the vector containing the min x,y coordinates of your bounding box and
BB.max is the vector containing the max x,y coordinates
and BB.size = 2 (2d bounding box)
« Last Edit: August 26, 2021, 11:29:48 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

Natsumi

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How do you set the boundaries?
« Reply #2 on: August 27, 2021, 08:38:30 AM »
Hi Paulo,

Thank you for teaching me
I made the code below, but it doesn't work.
What's wrong?


Code: [Select]
    doc = Metashape.app.document
    res_x = res_y = 0.0003
    BB = Metashape.BBox()
    minx = coordinates[ex_path][0]
    miny = coordinates[ex_path][1]
    maxx = coordinates[ex_path][2]
    maxy = coordinates[ex_path][3]
    BB.min = Metashape.Vector([minx,miny])
    BB.max = Metashape.Vector([maxx,maxy])
    BB.size = 2

    compression = Metashape.ImageCompression()
    compression.tiff_compression = Metashape.ImageCompression.TiffCompressionLZW
    compression.tiff_big = True
    compression.jpeg_quality = 99
    compression.tiff_overviews = True
    compression.tiff_tiled = True

    chunk.exportRaster(path = ex_path + '.jpg', image_format = Metashape.ImageFormatJPEG,clip_to_boundary=False,
    raster_transform=Metashape.RasterTransformNone,  region = BB,
    resolution_x = res_x, resolution_y = res_y,split_in_blocks = True, block_width = int(wid), block_height = int(pix2),
    white_background = True, save_alpha=True, source_data=Metashape.OrthomosaicData, image_compression = compression)

Paulo

  • Hero Member
  • *****
  • Posts: 1529
    • View Profile
Re: How do you set the boundaries?
« Reply #3 on: August 27, 2021, 08:50:01 AM »
Natsumi,

it seems your min max coordinates are suspect....

could you print out the values of minx,miny,maxx and maxy?

also the resolution is very fine 0.3 mm, are you sure? is this close range photogrammetry?

Note that your tiff_compression parameters will only apply if you export in TIFF format...

« Last Edit: August 27, 2021, 08:55:15 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

Natsumi

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How do you set the boundaries?
« Reply #4 on: August 27, 2021, 08:51:28 AM »
Hi Paulo,

I'm sorry.
As you told me.
I was reversing the maximum and minimum values.

Thank you for moving safely.