# Converting Roblox X,Y,Z to Latitude and Longitude

1. What do you want to achieve? Keep it simple and clear!

Convert a Roblox Player’s Coordinates (X, Y, and Z) to a Real World Latitude and Longitude Position, where it can be packaged into a JSON file then sent to an API server where is can be Decoded and get Map Data of the Latitude and Longitude coordinates. After the map data is parsed and interpreted, the corresponding map data will be returned to the Roblox Server in one long JSON file, where the parts and textures can be loaded into the workspace.

1. What is the issue?

I have literally no idea how to do this, I’ve tried googling it but there is no useful resources and the resources that I did find gave me a Brain Aneurism before reading the first sentence.

1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have looked on the DevForum and only found some very vague topics that weren’t really trying to do what I am doing.

Is this supposed to be latitude and longitude on earth?
Is it based on their real location or some focal point?
Do you want it based on their country from localizationservice? Perhaps you want it based on the GeographicLatitude property in workspace?

Im not quite sure what you want and I think some specificity would go a long way in helping you

Correct.

Just a Focal Point, not like a real location, just something that would safice.

Its not their real location, the game is called Roblox Earth, it’ll basically be a simulation of the Earth using Google Earth Engine.

The mathematical term to Google for the topic is cartesian coordinates to spherical coordinates as latitude and longitude so something like this topic In stack exchange to do the conversion.

local function getCoords(v)
local lat = math.atan2(v.Y, math.sqrt(v.X ^ 2 + v.Z ^ 2))
local lon = math.atan2(v.X, v.Z)
return lat, lon
end

The equations are about the same as in the wikipedia article, but I reversed the fraction for latitude since spherical coordinates measure elevation from the vertical axis, where in a latitude/longitude system I would assume you want to measure from the equator.

6 Likes