# Accessing Coordinates of Astronomical Data, e.g. Declination of all Galaxies

I am trying to access the coordinate information of all galaxies, stars, etc, available to the new astronomical data incorparated to Mathematica. However, the suggested (documented) approach fails. Trying to get the declination for al objects in GalaxyData[] I tried:

QuantityMagnitude@UnitConvert[GalaxyData[GalaxyData[], "Declination"], "degrees"];


here, GalaxyData[GalaxyData[], "Declination"] is the actual database access part, the rest of the expression tries to get rid of all the units. However, I get many error messages and finally it aborts. The error message reads:

The error is the same if I replace GalaxyData with StarData. The same approach works though if I query the "AparentMagnitude" property, or e.g. "DistanceFromSun". Any idea how to work around this?

This has something to do with the level of lists (but I'm not sure why properties like "DistanceFromSun" behave differently than properties like "Declination").

Using PlanetaryMoonData because is has fewer members, I have found that you can work around this by adding a PropertyAssociation annotation:

data = PlanetaryMoonData[PlanetaryMoonData[], "Declination", "PropertyAssociation"]


That is probably the cleanest way, although it returns an association, so you would need to extract the values:

QuantityMagnitude@UnitConvert[Flatten@Values@data, "Degrees"]


Alternatively, you could also map over the list of all data

PlanetaryMoonData[#, "Declination"] & /@ PlanetaryMoonData[]


to get a list of declinations, but I found this to be much slower (presumably because you query the database many more times).

• Great, thanks! One small correction though, you have to use "degrees" instead of "Degrees". A pity the AstronomicalData behaves somehwat unpredictable. – Markus Roellig May 8 '15 at 14:48
• @MarkusRoellig, happy to help. I agree that all of the astronomical data needs a little ironing out (although it is nice to have it). And, actually "Degrees" is more proper (everything in Mathematica is capitalized); using "degrees" will trigger a unit interpretation, which adds an extra step. – Virgil May 8 '15 at 14:54