# Projecting 2D points on to a sphere

I have computed a list of data where the elements of my data list are of the following type:

RGBColor[0.8895841739153035, 0.6096297985979048, 0.2226442872878191],
Point[{-0.000286314, 0.00616339}]


That is, each element consists of an RGBColor[X,Y,Z], together with a Point[{theta,phi}]. I can plot this in 2 dimensional cartesian coordinates using Graphics:

 Graphics[SphData]


giving me this:

I want to plot this now in 3-dimensions, using the two coordinates of each point as the angle coordinates for polar coordinates (the points should lie on a sphere with radius 1). The picture would look something like this:

but with coloured points.

• See FromSphericalCoordinates and then use Graphics3D. – Vitaliy Kaurov Oct 7 '17 at 23:47
• What have you tried and where did you get stuck? Use ReplaceAll to apply the appropriate transformation to each Point. – Szabolcs Oct 8 '17 at 11:23
• If Graphics3D works the way I hope it does, then I guess I would like to implement a rule which takes each entry {Colour, Point(theta,phi)} of my list to a new entry {Colour, newPoint(x,y,z)}. At the moment, I don't know how to change Point{theta,phi} to Point{r,theta,phi}, to which I would then apply the transformation rule. – Mark B Oct 10 '17 at 3:25

Ok, I have figured it out. Following the comment by Vitaliy Kaurov, the easiest way seems to be to use Graphics3D.
I first extracted data points and colour points into seperate lists using combinations of Flatten, Span and Part. Then, I used a ReplaceAll rule to take each of my entries (theta,phi) to (r,theta,phi):
ReplaceAll[Point[{a_,b_}]->Point[{1,a,b}]][datapoints]

Then I needed to apply a map taking my each point (r,theta,phi) to the corresponding point (x,y,z) in Cartesian coordinates. I did this with another ReplaceAll, together with CoordinateTransformData (I had some problems with fiddling this out, since you have to apply CoordinateTransformData to {r,theta,phi}, not Point[{r,theta,phi}], but I figured it out eventually).
Finally, I converted my triples {x,y,z} into Point[{x,y,z}] with a ReplaceAll, then used Riffle to put the coordinates back together with the colour list I took out from the start. Graphics3D applied to the final list gives me the required picture: