Forum

Author Topic: Export shapes to gpkg file  (Read 4319 times)

dcsa

  • Newbie
  • *
  • Posts: 12
    • View Profile
Export shapes to gpkg file
« on: February 10, 2024, 07:03:18 PM »
Dear Metashape developers,

We need to export a geometry in a GeoPackage file, but executing code:
Code: [Select]
layer = chunk.shapes.groups[0]
chunk.exportShapes(
     path=os.path.join(output_path, 'roi.gpkg'),
     save_polygons=True,
     groups=[layer.key],
     format=Metashape.ShapesFormatGeoPackage,
     crs=chunk.crs
)

We get error: OSError: SQL logic error (1)

But we do not get any error using the SHP format:

Code: [Select]
layer = chunk.shapes.groups[0]
chunk.exportShapes(
    path=os.path.join(output_path, 'roi.shp'),
    save_polygons=True,
    groups=[layer.key],
    format=Metashape.ShapesFormatSHP,
    crs=chunk.crs
)

Please, what is the solution to get our geometry exported in GPKG format?

Thank you for your time
« Last Edit: February 10, 2024, 07:08:00 PM by dcsa »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15420
    • View Profile
Re: Export shapes to gpkg file
« Reply #1 on: February 12, 2024, 10:50:06 AM »
Hello dcsa,

Your code works for some random projects and GeoPackage export on our side. Can you please check, if you are able to use the same code for the newly created shapes? If so, then probably there is something uncommon for shape attributes, labels or layer label?
Best regards,
Alexey Pasumansky,
Agisoft LLC

dcsa

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Export shapes to gpkg file
« Reply #2 on: March 20, 2024, 02:48:49 PM »
Hello Alexey,

Sorry for the delay in my reply and thank you for yours.

With a polygon created with the drawing tool in the metashape GUI, no error appears and I can export to .gpkg.

We have upgraded to version 2.0.2 and now it works without problem, even with the same geometry imported before (not the one drawn in the GUI).

Thanks again