# Change units in PlanetData[“Earth”, “Diameter”] from miles to km

When I enter

AstronomicalData["Earth", "Radius"]


I get Quantity[6.3674447*10^6, "Meters"]

I would have preferred kilometers, but I can live with meters.

Now there is a newfangled PlanetData command which gives the radius of the Earth in miles.

I know I can convert

UnitConvert[PlanetData["Earth", "Radius"], "SI"]
Quantity[6371.008, "Kilometers"]


But that is just silly! Is there a way to tell Mathematica to always use SI when applicable?

• What does $UnitSystem return? I get "Metric", and radius in meters (v11.0, Ubuntu 16.04). – anderstood Jan 17 '18 at 1:49 • May be related: 117916. Something I don't get is why does "SI" returns kilometers. The SI unit for lengths in meter, not km?! – anderstood Jan 17 '18 at 2:00 • @anderstood. That's because to get true SI base units, you need to leave the target units argument blank, which causes MMA to default to "SIBase": UnitConvert[PlanetData["Earth", "Radius"]] or, equivalently, UnitConvert[PlanetData["Earth", "Radius"], "SIBase"] When you instead specify "SI", MMA selects the "common" metric unit that gives a numeric value closest to 1 ("common" in this case means km, rather than Mm, even though Mm would give a qty closer to 1). As another example, compare: UnitConvert[Quantity[.0001, "Inches"]] to UnitConvert[Quantity[.0001, "Inches"], "SI"] – theorist Jan 17 '18 at 2:22 • I'll add that km is an accepted SI unit for length (since prefixes are allowed in SI), it's just not the base unit, which is meters. – theorist Jan 17 '18 at 2:34 • @Anderstood$UnitSystem on V10.x MicroS*** returns Imperial. As for getting friendly SI units. I'm good with that. – Steven Thomas Hatton Jan 17 '18 at 5:01

You can use the UnitSystem option of EntityProperty,

EntityValue[Entity["Planet", "Earth"],
EntityProperty[
"Planet",
UnitSystem -> "Metric"
]
]
(* Quantity[6371.008, "Kilometers"] *)


Why am I talking about EntityValue when you asked about PlanetData? Because PlanetData calls EntityValue under the hood (as do all newer XXXData functions).

If you still want to use the PlanetData function, you can do the following,

SetOptions[
EntityProperty,
UnitSystem -> "Metric"
]
(* {UnitSystem -> "Metric"} *)

PlanetData[
"Earth",

If you would like this option to be persistent across kernel sessions, you can add the SetOptions line above in your init.m file, whose location is described here.