1
$\begingroup$

I am trying to construct a variable in a dataset that calculates the distance from a point to a city/country listed in another variable. I hoped to use GeoPosition to get the approximate location of the city or country. Sometimes these are "locations" that GeoPosition cannot find, and I'm happy to accept a blank or missing value as the location, but GeoPosition gives a failure message: GeoPosition failure with nonsense city

The failure message seems to cause the dataset variable processing to halt. I cannot seem to suppress or mask the failure message (Quiet doesn't work). Any suggestions on how to gracefully handle a GeoPosition failure by returning a blank and continuing on to process the remaining rows in the dataset? Thanks!

$\endgroup$

1 Answer 1

2
$\begingroup$

Using FailureQ:

If[FailureQ[#], {}, #] &@Interpreter["Location"]["Paris"]

GeoPosition[{48.86, 2.34}]

If[FailureQ[#], {}, #] &@Interpreter["Location"]["ParisBerlin"]

{}

$\endgroup$

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.