4
$\begingroup$

I have an entity city. For example, I run {city} = GeoNearest["City", GeoPosition[{41.8, -87.7}]] and then I got The entity "Chicago" as my output of city.

I want to have the string "Chicago" instead entity "Chicago" as output.

How can I convert city from entity to string?

Many thanks!

$\endgroup$
4
$\begingroup$

Every Entity should have a "Name" property that returns a string,

enter image description here

If you have city defined as an entity, these three give the same result

city @ "Name"
EntityValue[city, "Name"]
EntityProperty["City", "Name"] @ city
|improve this answer|||||
$\endgroup$
  • $\begingroup$ Keeping in mind that GeoNearest returns a list, if you want to define your variable in one line, you can use this: city=First[GeoNearest["City", GeoPosition[{41.8, -87.7}]]]["Name"] $\endgroup$ – kickert Jul 2 '18 at 16:01

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.