A friend said to me on Facebook that she is 4000km away. So I want to try to guess where she is.
How can I find which countries are a given distance from my current location?
A friend said to me on Facebook that she is 4000km away. So I want to try to guess where she is.
How can I find which countries are a given distance from my current location?
Thanks to Simon Woods' advises it should now be correct.
Taking the OP's informations:
loc = {46.72, 25.59};(*CityData["Gheorgheni","Coordinates"]*);
dist = 4*10^6;(*distance in m*)
bounds = Table[GeoDestination[loc, {dist, i}][[1]], {i, 0, 360, 1}];
Graphics[{EdgeForm@Thin, Red, Polygon[Reverse /@ bounds], Opacity@.33,
EdgeForm[Thin], FaceForm[LightGray],
Tooltip[CountryData[#, "SchematicPolygon"], #] & /@ CountryData[]},
ImageSize -> 700]

Of course, the same can be done with your own location: loc = $GeoLocation.
GeoDistance[loc, #] & /@ bounds are then all equal to 4000 km.
Checking which countries are exactly on the 4000 km border (and thanks to rm-rf answer here):
countriesCoor =
First /@ (CountryData[#, "Coordinates"] & /@ CountryData[]);
inPolyQ[poly_, pt_] := Graphics`Mesh`PointWindingNumber[poly, pt] =!= 0
crossedCountriesPos =
Flatten@DeleteDuplicates[
Table[Position[inPolyQ[#, bounds[[i]]] & /@ countriesCoor,True],
{i, 1, Length@bounds, 1}] /. {} :> Sequence[]];
crossedCountries = CountryData[][[#]] & /@ crossedCountriesPos;
crossedCountries // Short
insideCountries = CountryData[][[#]] & /@
Flatten@Position[
inPolyQ[bounds, #] & /@ (CountryData[#, "CenterCoordinates"] & /@
CountryData[]), True];
insideCountries // Short
Countries lying on the 4000 km border:
{Russia,Kazakhstan,China,Kyrgyzstan,Pakistan,Oman,Yemen, <<5>>, Chad,Cameroon,Nigeria,Niger,Mali,Mauritania,WesternSahara}
Countries inside the 4000 km area:
{Afghanistan,Albania,Algeria,Andorra,Armenia,<<73>>, UnitedArabEmirates,UnitedKingdom,Uzbekistan,VaticanCity,WestBank}
Graphics[{EdgeForm@Thin, Red, Polygon[Reverse /@ bounds], Opacity@.33,
Black, CountryData[#, "SchematicPolygon"] & /@ insideCountries, Blue,
CountryData[#, "SchematicPolygon"] & /@ crossedCountries,
FaceForm[Lighter@LightGray],
Tooltip[CountryData[#, "SchematicPolygon"], #] & /@ CountryData[]},
ImageSize -> 700]

GeoDistance[loc, endCircle] doesn't even return 4000km.
– Öskå
Jun 14 '14 at 17:44
loc as {lat, long} and do the Reverse after GeoDestination, i.e. bounds = Table[Reverse@GeoDestination[loc,...
– Simon Woods
Jun 14 '14 at 18:26
Polygon[Reverse /@ bounds] in the graphics.
– Simon Woods
Jun 14 '14 at 18:40
Using the new geographic tools in Mathematica 10:
GeoGraphics[
GeoCircle[
GeoPosition[Entity["City", {"Gheorgheni", "Harghita", "Romania"}]
],
Quantity[4000, "km"]
],
GeoBackground -> "StreetMap", (* To get country labels *)
ImageSize -> 800
]

WRI posted another example on Twitter.
There is another tool called GeoIdentify that returns all regions of the selected type that a path crosses. This can give us a list of countries to complement our visualization:
countries = GeoIdentify[
"Country",
GeoCircle[
GeoPosition[Entity["City", {"Gheorgheni", "Harghita", "Romania"}]
],
Quantity[4000, "km"]
]
]
Out:

The GeoIdentify documentation has some ideas about how visualize this as well. Combining our previous code with this styling gives us:
geocircle = GeoCircle[
GeoPosition[Entity["City", {"Gheorgheni", "Harghita", "Romania"}]
],
Quantity[4000, "km"]
];
GeoGraphics[{
(Tooltip[{GeoStyling[Opacity[.5]], RandomColor[], Polygon[#1]}, CommonName@#1] &) /@ countries,
geocircle
},
GeoRange -> geocircle,
ImageSize -> 800
]

If you think Spain doesn't look like it intersects the circle, recall the position of the Gran Canary Islands. (Since it is a popular tourist destination it's a good guess that that is where the OP's friend is.)
EDIT: Since the animation was generated I have replaced the tooltips according to rcollyers suggestion. The tooltip label is now the CommonName of the country entity instead of the entity itself (labels now look the way you expect them to.)
CommonName@# for the second argument in Tooltip? Oh, and you already had my +1.
– rcollyer
Jul 22 '14 at 18:06
I am assuming you have Mathematica with you. So here's some quick and dirty way to get the info you require. I think it is very interesting to do this
currentLocation =
GeoPosition[
CountryData[
StringTrim[
StringSplit[
WolframAlpha[
"Current GeoIP location", {{"HostInformationPod", 1},
"ComputableData"}][[2, 2]], ","][[3]]], "CenterCoordinates"]];
countries = CountryData[];
geopos = GeoPosition[CountryData[#, "CenterCoordinates"]] & /@ countries;
distances = GeoDistance[currentLocation, #] & /@ geopos;
countriesAround4000km = CountryData[][[#]] & /@ Position[distances, _?(# < 4.1*10^6 && # > 3.9*10^6 &)]
currentLocation = GeoPosition[FindGeoLocation[]]; without WA call
– arvind
Jun 14 '14 at 16:10
GeoDestination) so I edited it to not be about W|A any more. – Simon Woods Jun 14 '14 at 19:33nearLC. – Artes Jun 14 '14 at 20:34