Forum

Author Topic: Crop Raster by boundaries  (Read 2007 times)

pedrounas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Crop Raster by boundaries
« on: March 17, 2021, 12:48:22 PM »
Hello,

I am trying to limit the area of the generated Ortomosaic using a .gpkg file as boundaries, importing it as such:
Code: [Select]
        self.chunk.importShapes(
            path='limits.gpkg',
            boundary_type=Metashape.Shape.OuterBoundary,
            format=Metashape.ShapesFormat.ShapesFormatGeoPackage, crs=v_projection)

And when exporting the raster I am using the flag clip_to_boundary=True:
Code: [Select]
        self.chunk.exportRaster(path='ortomosaic.tiff',
                                image_format=Metashape.ImageFormatTIFF, projection=projection, clip_to_boundary=True)

Despite this the generated file is still the same as when I did not try to crop it.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Crop Raster by boundaries
« Reply #1 on: March 17, 2021, 04:07:10 PM »
Hello pedrounas,

Can you please check, if the imported shapes have at least one polygon?

Also I can suggest to debug the problem in the application GUI:

1. Try to import the shapes and check, if the boundary is applied.

2. Try to export the orthomosaic, providing that the boundary shapes do exist.

I was not able to reproduce the problem on some random project.
Best regards,
Alexey Pasumansky,
Agisoft LLC

pedrounas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Crop Raster by boundaries
« Reply #2 on: March 17, 2021, 06:41:13 PM »
The file contains one polygon which is an area inside of the larger Ortomosaic. I cannot try in GUI as I only have access to the API.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Crop Raster by boundaries
« Reply #3 on: March 17, 2021, 09:31:52 PM »
Hello pedrounas,

Please try to print out the following lines after importing shape for debugging:

Code: [Select]
shape = self.chunk.shapes[-1]
print(shape.type)
print(shape.boundary_type)
print(len(shape.vertices))
print(self.chunk.shapes.crs)
print(self.chunk.orthomosaic.crs)

Can you post the output here?
Best regards,
Alexey Pasumansky,
Agisoft LLC