Forum

Author Topic: Export shapes with same coordinate system as custom-view orthomosaic  (Read 1342 times)

PeterBetlem

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hi!

I have been struggling with an otherwise very simple task: exporting annotations and shapes in the same coordinate system as used for the orthomosaic.
The export works as expected when the orthomosaic is top-view and has a "normal" crs. However, I have not been able to export "projected" shapes from a custom-view or side-view orthomosaic.

In this case, my custom-view orthomosaic uses epsg:4978, but with negative X and huge Y coordinates, e.g.:
WGS 84 (EPSG::4978) -1931.398 X 6357705.971 Y

Obviously, there is a working transform - as the shapes are successfully printed on this side-view. Would anyone be able to help me out and point me to the obvious; any idea on how to access this transform and use it for the export of the shapes in the same coordinate system as the orthomosaic?

Any help is greatly appreciated!



Paulo

  • Hero Member
  • *****
  • Posts: 1321
    • View Profile
Re: Export shapes with same coordinate system as custom-view orthomosaic
« Reply #1 on: February 15, 2022, 02:09:08 AM »
Hello Peter,

to get the shapes  coordinates in the  exported custom view ortho CS, you need to apply the orthomosaic projection matrix to each shape geocentric coordinates (EPSG 4978).

Given a selected shape s, then the  coordinates of each vertex v in the orthomosaic custom view (side) CS are O.mulp(chunk.shapes.crs.unproject(S.inv().mulp(v))) where:
Code: [Select]
chunk = Metashape.app.document.chunk
O = chunk.orthomosaic.projection.matrix
S = chunk.shapes.projection.matrix
for s in [s for s in chunk.shapes if s.selected]:
    if s.geometry.type == ps.Geometry.PolygonType:
        for v in s.geometry.coordinates[0]:
            print(s.label,O.mulp(chunk.shapes.crs.unproject(S.inv().mulp(v))))
    else:
        for v in s.geometry.coordinates:
            print(s.label,O.mulp(chunk.shapes.crs.unproject(S.inv().mulp(v))))
see attachment

A script could always be developped to export the shapes in the custom ortho projection in csv format for example...

« Last Edit: February 15, 2022, 06:57:38 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor