4
$\begingroup$

I am trying to convert degree to number for some mathematical transformation. Taking London as an example, the following codes can convert the degree into a number without any problems:

Codes that give numbers {51.5,-0.11} and {0.8988,-0.0019} as output:

{51.5°,-0.12°} /Degree
{51.5°,-0.12°} /. GeoPosition -> Identity

However, I want to use London as the input. In fact, if I input

LatitudeLongitude[Entity["City",{"London", "GreaterLondon", "UnitedKingdom"}]]

I can get {51.5°,-0.12°} without a problem.

The problem is, when I combine the two, the result fails to convert into number. It is still in degrees.

Codes that still give degree as output:

LatitudeLongitude[Entity["City",{"London", "GreaterLondon", "UnitedKingdom"}]]/Degree
LatitudeLongitude[Entity["City",{"London", "GreaterLondon", "UnitedKingdom"}]]/. GeoPosition -> Identity 

How can I convert that into degrees?

$\endgroup$

1 Answer 1

3
$\begingroup$

The output of LatitudeLongitude is a List of Quantitys:

pos = LatitudeLongitude[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}]]

FullForm@pos

List[Quantity[51.5`,"AngularDegrees"],Quantity[-0.1166667`,"AngularDegrees"]]

This would suggest to use UnitConvert:

UnitConvert[pos, "Radians"]

{0.898845rad,-0.00203622rad}

which again is a List of Quantitys:

FullForm@%

List[Quantity[0.8988445647770799`,"Radians"],Quantity[-0.0020362180424364686`,"Radians"]]

One could extract the numbers with [[All, 1]]. However, this whole line of reasoning leads to overcomplication of the procedure, as the straighforward approach is

Normal@pos

{0.898845, -0.00203622}

$\endgroup$
1
  • $\begingroup$ Thanks. Done with Normal[LatitudeLongitude [Entity["City",{"London", "GreaterLondon", "UnitedKingdom"}]]]/Degree as suggested. $\endgroup$
    – H42
    Commented Apr 19, 2018 at 0:27

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.