# How to properly convert from WKT to euclidean 3d points?

I am not a geoscientist (I do computer graphics), however I am trying to render some geospatial data encoded as a WKT file.

I have a `POLYGON` with 2 coordinates per point, which seems to be representing latitude and longitude values (this is a guess on my end).

I use spherical coordinates to map these points onto euclidean (x,y,z) points for rendering.

The first problem I am having is, I am calculating latitude as an angle from the z axis (which matches the north pole) and latitude from the x axis (which seems to intersect with Greenwich meridian).

To my understanding this should guarantee correct positioning, alas what I get is a very misplaced Canada. Moreover, even when I manage to place the border on the correct region, it is clear the border outline is highly deformed with regard to the earth sphere. This is the projection formula I am using to project the border:

``````Eigen::Vector3d SphericalCoordinatesToEuclidean(const Eigen::Vector2d& point)
{
const double longitude = (point.y()) * 2.f * M_PI / 360.f;
const double latitude = (point.x()) * 2.f * M_PI / 360.f;

return {
sin(latitude) * sin(longitude), sin(latitude) * cos(longitude), cos(latitude)};
}
``````

The full data set is gigantic, this is just the section comprising the canadian border (every 2 values seem to be a point):

https://gist.github.com/Makogan/1aec1ea701ae3c8cb3653506bc9d8873

• `Longitudes -> X | Latitudes -> Y`. Latitudes origin at the Equator with an extent of `+/-90°` (180°). Jun 17 at 7:16
• what a silly mistake on my end. Jun 17 at 18:14
• yeah, I consider myself to be extraordinarily familiar with these two, yet I I have to give it two seconds each time I go Euclidean with them...how did it go? Might want to self answer the solution, if it worked. Jun 17 at 19:16
• That was the problem, I swapped the coordinates, and also my angle must be computed from the equator not the axis of rotation, so I had to add pi / 2 to the latitude Jun 17 at 20:29