I´m trying to calculate the GeoDistance of 50.000 Latitude-Longitude positions to 1 Latitude-Longitude position. But after a while Mathematica 10.1 shows the message: A network operation for GeoDistance timed out. Please try again later.
It would help if you posted your actual code and not a screen shot.
But to your problem. I am guessing that indeed sometimes the network operation (sending and retrieving from the Wolfram cloud servers) is not completing in the required time. It can happen when so many requests are being sent to it. So, if that is the case, you should build some redundancy into your code so that if a request to the Wolfram servers returns $Failed, you try to sent the request again (and you can write code to do that more than one time if you wish).
But without the code is hard to test and reproduce your experience.
Best to use the tools at the top of the input area to paste code into a code area…
Of course your code cannot be tested with out the external file you are using…
But to your question, simply use an If statement that tests whether the GeoDistance computation returns
$Failed
as it was for some of your computations. If it returns $Failed then the If statement should try again. If that returns
$Failed
then you can substitute some default value. This is for trying only one extra time. If you want to try n>1 additional times then use another construct such as a While statement or a Do loop that only tries n time.
I solved it using GeoPosition instead of GeoMarker. But the distances differ, GeoDistances calculated with GeoPosition are different than calculated with GeoMarker.
What are the values of data[[i]][[1]] ? Are they pairs {lat, lon} or GeoPosition objects or Entity objects?
When GeoDistance gets a pair of GeoPosition objects, the distance computation is performed locally in your computer, which is faster. When GeoDistance gets Entity objects or geo primitives (like GeoMarker) the computation is performed in the Wolfram geo server because it may involve accessing data about polygons, etc, which is accessed faster in the geo server, but there is the penalty of the transmission time. With point-to-point computations (i.e. not involving polygons) the results should be very similar.
When you have lots of {lat, lon} pairs, it is worth grouping them in a single GeoPosition object. For example, take 50000 random geo locations:
The result is a QuantityArray expression containing 50000 values in miles. Use Normal to get a list of Quantity objects, or QuantityMagnitude to get a list of the respective numerical values (in miles).