I have a bunch of localities worldwide for which I need to check their geographic coordinates. So far, I only count on information on the corresponding countries, localities' names, and "suggested" latitudes and longitudes in decimal degrees. I'm wondering if is there any 100% free tool (ideally an R package) that allows me to automatically check the degree of error of some coordinates. Ideally, I'm thinking about a system that (1) picks the information available, (2) checks it in some gazetteer or similar the localities around the provided coordinates (let's say, within a buffer of 20 km) and returns if there is a locality with a similar name within the buffer. Any idea?
1 Answer
This sounds like "geonames". Go to http://geonames.org/ for the full details, then try the R package. You'll need a geonames username from the site.
Amongst other things it can find the country at a lat-long point:
> library(geonames)
> options(geonamesUsername="myusernamehere")
> GNcountryCode(lng=-2.5, lat=54)
$languages
[1] "en-GB,cy-GB,gd"
$distance
[1] "0"
$countryCode
[1] "GB"
$countryName
[1] "United Kingdom of Great Britain and Northern Ireland"
or a set of nearby placenames:
> GNfindNearbyPlaceName(lng=-2.5, lat=54,radius=10)
adminCode1 lng distance geonameId toponymName countryId fcl
1 ENG -2.4383 5.52712 2637675 Slaidburn 2635167 P
2 ENG -2.53333 5.97867 2646965 Higher Thrushgill 2635167 P
3 ENG -2.46667 5.97959 2641562 Newton 2635167 P
4 ENG -2.52059 9.15351 2634050 Whitewell 2635167 P
population countryCode name fclName
1 0 GB Slaidburn city, village,...
2 0 GB Higher Thrushgill city, village,...
3 0 GB Newton city, village,...
4 0 GB Whitewell city, village,...
adminCodes1.ISO3166_2 countryName fcodeName adminName1 lat
1 ENG United Kingdom populated place England 53.96618
2 ENG United Kingdom populated place England 54.05
3 ENG United Kingdom populated place England 53.95
4 ENG United Kingdom populated place England 53.91866
fcode
1 PPL
2 PPL
3 PPL
4 PPL
-
1Thanks @Spacedman, but, curiously, it seems not to work 100% correctly. For example, I ask for
GNfindNearbyPlaceName(lng=-54.8, lat=-68.3,radius=50)
which corresponds to Ushuaia, Argentina, and even if the coordinates are correct, the answer I got wasdata frame with 0 columns and 0 rows
. Jun 16, 2020 at 23:34 -
1@perep1972 you've got lat-lng the wrong way round. Try:
GNfindNearbyPlaceName(lng=-68.3, lat=-54.8,radius=50)
- Ushuaia is the first return. Jun 17, 2020 at 0:02