Looking to see how to extract out just the length for this search:

formerSovietUnion = {"Armenia", "Azerbaijan", "Belarus", "Estonia", 
"Georgia", "Kazakhstan", "Kyrgyzstan", "Latvia", "Lithuania", 
"Moldova", "Russia", "Tajikistan", "Turkmenistan", "Ukraine", 
totalKilometers = CountryData[#, "RailwayGaugeLengths"][[1, All]] & 
/@ formerSovietUnion
  • 1
    $\begingroup$ CountryData[#, "RailwayGaugeLengths"][[1, -1]] & /@ formerSovietUnion? $\endgroup$ – kglr Nov 18 '18 at 13:44
  • 1
    $\begingroup$ Use Values on the result list. $\endgroup$ – Szabolcs Nov 18 '18 at 13:50

Mapping over entities for properties is less efficient than calling EntityValue with a list of entities.

Create the country entities.

fsu = Thread[Entity["Country", formerSovietUnion]]

Mathematica graphics

There are several metrics available

EntityValue[fsu, "RailwayGaugeLengths"]

and although its in the name you can check the units directly.

EntityValue[EntityProperty["Country", "RailwayGaugeLengths"], "Unit"]

You may use Query to access the values.

Total per country

Query[All, "TotalKilometers"]@res
{845., 2122., 5538., 919., 1612., 13700., 470., 2298., 1765., 1138., 87157., 680., 2980., 21655., 3645.}

Grand Total

Query[Total, "TotalKilometers"]@res

Other summary functions

Query[{Min, Max, Mean, Median, StandardDeviation}, "TotalKilometers"]@res
{470., 87157., 9768.27, 2122., 22190.}

Including visualisations like BoxWhiskerChart

Query[BoxWhiskerChart[#, "Outliers", BarOrigin -> Left] &, "TotalKilometers"]@res

Mathematica graphics

and so on.

Hope this helps.

  • $\begingroup$ This might be cleaner as you're able to ditch the List, even: EntityValue[EntityClass["Country", "FormerSovietUnionMembers"], EntityProperty["Country", "RailwayGaugeLengths"] ]~Lookup~"TotalKilometers". On the other hand I was expecting there to be a qualifier to specify the track gauge but it doesn't look like there is. $\endgroup$ – b3m2a1 Nov 18 '18 at 20:50

The result from your code is: Result from code

Applying the function Values gives

totalKilometers // Values

result from applying Values

Finding the total length is then computed through applying Total

totalKilometers // Values // Total

total length


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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