Forum

Author Topic: How to use the crs argument with importReference to add a local crs  (Read 2262 times)

john.awad

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hello,

I'm using a script in Metashape 1.6.3 to automate a large amount of models. I have coded targets on my scene and I'm using these 2 lines to detect and reference them:

Code: [Select]
chunk.detectMarkers(target_type=Metashape.CircularTarget12bit, tolerance=100, filter_mask=False, inverted=False, noparity=False, maximum_residual=5)
chunk.importReference(path=calibFolder + "\\" + "Markers" + ".txt", format=Metashape.ReferenceFormatCSV, columns='nxyz', delimiter='\t', create_markers=False)

Where the Markers.txt file contains the reference targets and their coordinates (attached).

The reference marker locations are manually picked from a model that is scaled and registered to a LiDAR scan, and are in mm local coordinates as such: LOCAL_CS["Local Coordinates (mm)",LOCAL_DATUM["Local Datum",0],UNIT["millimetre",0.001,AUTHORITY["EPSG","1025"]]]

I would like to import those reference markers and give them this local crs in mm. I know how to manually do it, as per this article: https://www.agisoft.com/forum/index.php?topic=6427.0 but I don't know how to use the crs argument for the importReference command in python.

According to the documentation: importReference(path=’‘, format=ReferenceFormatCSV, columns=’‘, delimiter=’‘, group_delimiters=False, skip_rows=0[, items ][, crs ], ignore_labels=False, create_markers=False, threshold=0.1, shutter_lag=0[, progress ])

How do I use the crs argument? Could you show me an example? Also according to the documentation, the crs needs to be in csv. Could you also show me an example of a corresponding file?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: How to use the crs argument with importReference to add a local crs
« Reply #1 on: September 17, 2020, 07:40:16 PM »
Hello John,

Please see and example below, which creates CoordinateSystem object for your custom coordinate system and then uses it when the coordinate information is imported:

Code: [Select]
crs = Metashape.CoordinateSystem('LOCAL_CS["Local Coordinates (mm)",LOCAL_DATUM["Local Datum",0],UNIT["millimetre",0.001,AUTHORITY["EPSG","1025"]]]')
chunk.importReference(path=path, format=Metashape.ReferenceFormatCSV, columns='nxyz', crs = crs, delimiter='\t', create_markers=False)
Best regards,
Alexey Pasumansky,
Agisoft LLC

john.awad

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to use the crs argument with importReference to add a local crs
« Reply #2 on: September 21, 2020, 01:12:32 PM »
Thank you so much! That's exactly what I needed.