Convert local coordinates to lat lon


Hi guys,

I’m building a GIS app and wanted to add a feature to display the lat lon coordinates of my camera pivot in real-time.

This is how I setup my interaction:

  1. Created a Data Table.
  2. Added a EntitySetProperty action to it.
  3. I set its target to a text entity.
  4. Its start_expr is set to dt://CamPivot/@position.

My text entity is updated every .1 second and the 3D coordinates are displayed with no issues (Looks pretty cool :smiley:).

That being said, these are not so relevant for the end user in my case. It would be awesome if I could somehow convert these coordinates to lat lon. Found a couple of formulas online but it’s usually to do the opposite.

I’m supposing that I would need at least 2 anchor dummies placed at different locations on my 3D environment containing the actual lat long coordinates information. And then write an expression to compute the lat long coordinates of my camera pivot referenced to the anchor dummies.

Let me know if you have any clues on how this can be achieved.


1 Like


Yes, it shouldnt be too difficult, but as you suspect you need to add some information to convert the 3D position into a Lat/Lon.

A simple approximation should do for your use case - so we assume a flat plane which for a small area (< 100000km2) is fine. That is you would put one anchor DataTable at the North/West position and another at the South/East position, then write the lat/lon in two properties. Note that the DataTable entity behaves as a Dummy so its does have a 3D position.

So the EntitySetProperty start_expr it would look something like this:

  'x', GetX(dt://CamPivot/@position),
  'minX', GetX(dt://NW/@position),
  'maxX', GetX(dt://SE/@position),
  'minLat', GetX(dt://NW/@lat),
  'maxLat', GetX(dt://SE/@lat),
  'normalizedX', (Get('x') - Get('minX')) / (GetX('maxX') - GetX('minX')),
  (Get('normalizedX') * (GetX('maxLat') - GetX('minLat'))) + GetX('minLat'))
  1. We retrieve the values so that we dont have to type all the dt:// every time
  2. We normalize the position (so that its a value between 0 & 1)
  3. We use the normalized value to return a latitude / longitude

A few notes:

  • Set sets a bunch of named values & Get retrieves them.
  • Set returns the last expression “as-is”, it doesn’t need to be named.
  • I might have swapped/screwed up what is Latitude and what’s Longitude you’ll need to try it out and maybe fix it up…
  • Use the GetZ to get the other coordinates… (longitude in my example)


Thanks for the help. I’m getting a “-nan[ind]” returned though, I’ll check it in more details later on.



NaN (Not a number)/Inf (Infinity) would be because you divide by zero somewhere, my guess is that the properties are maybe not setup correctly in one of the DataTable. Or you have both position at 0,0,0…