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:

enter image description here

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?


1 Answer 1


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).

  • $\begingroup$ Great, thanks! One small correction though, you have to use "degrees" instead of "Degrees". A pity the AstronomicalData behaves somehwat unpredictable. $\endgroup$ Commented May 8, 2015 at 14:48
  • $\begingroup$ @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. $\endgroup$
    – Virgil
    Commented May 8, 2015 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.