Forum

Author Topic: WGS84 to local coordinates (m) with false easting/northing projection (PRJ)  (Read 4643 times)

LRP

  • Newbie
  • *
  • Posts: 24
    • View Profile
I am exploring getting WGS84 coordinate Laser scans and drone data exported to e57/FBX file using a marker as a pre-determined local coordinate. It seems this can be done with a custom projection file? I am not familiar with the syntax. Hoping someone can provide an example or shed some light on this. Thanks in advance.
« Last Edit: November 03, 2023, 05:42:01 PM by LRP »

LRP

  • Newbie
  • *
  • Posts: 24
    • View Profile
bump

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15159
    • View Profile
Hello LRP,

Conversion between two geographic coordinate systems is possible either if both are defined on the same datum or if both have ToWGS84 transformation parameters defined. I doubt that it is possible to make a transformation from world coordinate system (WGS84) to the local Cartesian system with high accuracy.

What is the target coordinate system is it really local of geographic/projected?
Best regards,
Alexey Pasumansky,
Agisoft LLC

LRP

  • Newbie
  • *
  • Posts: 24
    • View Profile
Alexey. here is a thread that took me down this path for the coordinate conversion, specifically mesage 10 by Pointdump:

https://forums.autodesk.com/t5/civil-3d-forum/changing-world-0-0-point-in-a-georeferenced-file/td-p/9714275

I am trying to get Metashape data to Autodesk 3DSMAX while being able to set the point of origin of the data, ideally, to one of the markers - maybe this can be done through another method.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15159
    • View Profile
Hello LRP,

Can you please try to check, if the following script gives you the desired result for the mesh model export in FBX format?

You need to have one 3D marker selected before running the script. The model should be exported in local space Euclidean coordinate system that has its origin in the point of the selected marker and has its axes parallel to the real world coordinate system axis in the given point:


Code: [Select]
import Metashape

def export_topocentric_by_marker():

doc = Metashape.app.document
chunk = doc.chunk
T = chunk.transform.matrix
crs = chunk.crs
if chunk.marker_crs:
crs = chunk.marker_crs

if not chunk:
print("Empty project, script aborted")
return 0
if not len(chunk.markers):
print("No markers, script aborted")
return 0
markers = [marker for marker in chunk.markers if marker.selected]
if len(markers) != 1:
print("Only one marker should be selected, script aborted")
return 0
marker = markers[0]
if not marker.position:
print("No 3D location for selected marker, script aborted")
return 0
if not chunk.model:
print("No active mesh model, script aborted")
return 0

path = Metashape.app.getSaveFileName("Specify export path for mesh", filter = "*.FBX")
if not path:
print("Empty path, script aborted")
return 0

WGS84 = Metashape.CoordinateSystem("EPSG::4326")
marker_wgs84 = WGS84.project(T.mulp(marker.position))
long, lat, alt = marker_wgs84


wkt2 = 'PROJCRS["EPSG topocentric example A",    BASEGEOGCRS["WGS 84",        DATUM["World Geodetic System 1984",            ELLIPSOID["WGS 84",6378137,298.257223563,                LENGTHUNIT["metre",1]]],        PRIMEM["Greenwich",0,            ANGLEUNIT["degree",0.0174532925199433]],        ID["EPSG",4979]],    CONVERSION["EPSG topocentric example A",         METHOD["Geographic/topocentric conversions",             ID["EPSG",9837]],         PARAMETER["Latitude of topocentric origin",{:.9f},             ANGLEUNIT["degree",0.0174532925199433],             ID["EPSG",8834]],         PARAMETER["Longitude of topocentric origin",{:.9f},             ANGLEUNIT["degree",0.0174532925199433],             ID["EPSG",8835]],         PARAMETER["Ellipsoidal height of topocentric origin",{:.3f},             LENGTHUNIT["metre",1],             ID["EPSG",8836]]],     CS[Cartesian,3],         AXIS["topocentric East (U)",east,             ORDER[1],             LENGTHUNIT["metre",1]],         AXIS["topocentric North (V)",north,             ORDER[2],             LENGTHUNIT["metre",1]],         AXIS["topocentric height (W)",up,             ORDER[3],             LENGTHUNIT["metre",1]],     USAGE[         SCOPE["unknown"],         AREA["To be specified"],         BBOX[-90,-180,90,180]]]'.format(lat, long, 0)
export_crs = Metashape.CoordinateSystem(wkt2)

chunk.exportModel(path, format = Metashape.ModelFormatFBX, crs = export_crs, save_metadata_xml = True, binary = False)

print("Script finished")
return 1

export_topocentric_by_marker()

« Last Edit: November 24, 2023, 03:49:16 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC