2
$\begingroup$

I'm trying to get a list of mountains containing the mountain's name, its elevation, and the country it's in. I still don't get the hang of Entities. I can get a list of mountains and their elevations as follows:

mountains = EntityClass["Mountain", "Elevation" -> TakeLargest[200]] // EntityList;
names = MountainData[#, "Name"] & /@ mountains;
elevations = MountainData[#, "Elevation"] & /@ mountains];

I've tried a lot of wrong ways to get the country. I see that there's an Administrative Division that's available, but I find myself descending into nested layers of properties.

$\endgroup$
1
  • $\begingroup$ There can be more than one, so the property you're after is "Countries". For example Mount Everest is in China and Nepal. $\endgroup$ Commented yesterday

1 Answer 1

5
$\begingroup$
list = MountainData[#, {"Name", "Elevation", "Countries"}] & /@ 
  EntityList@EntityClass["Mountain", "Elevation" -> TakeLargest[10]]

Grid[{#1, ToString[Round[#2], TraditionalForm], 
    CountryData[#, "Name"] & /@ #3} & @@@ list, Alignment -> Left]

Mount Everest          8849m    {China,Nepal}
K2                     8612m    {China,Pakistan}
Kangchenjunga          8586m    {India,Nepal}
Lhotse                 8516m    {Nepal}
Kangchenjunga West     8505m    {India,Nepal}
Yalung Kang            8505m    {India,Nepal}
Kangchenjunga South    8494m    {India}
Makalu                 8485m    {Nepal}
Kangchenjunga Central  8482m    {India}
Lhotse Middle          8410m    {China}
$\endgroup$
3
  • $\begingroup$ Kangchenjunga West and Yalung Kang is in fact the same mountain. I am not sure why it is listed twice, whether it is a bug in data or a feature that every mountain is listed as many times as many different names it has. $\endgroup$ Commented yesterday
  • 1
    $\begingroup$ +1. If desired, we could get all the data in a single query thus: EntityValue[ EntityClass["Mountain", "Elevation" -> TakeLargest[10]], {"Name", "Elevation", EntityFunction[e, CommonName /@ e["Countries"]]}] $\endgroup$ Commented yesterday
  • $\begingroup$ I wonder if the reason one mountain has multiple names is because ownership is disputed across the border? $\endgroup$ Commented 15 hours ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.