Google has a Geocoding program which is capable of taking string data and then converting it into long/lat co-ordinates. We are all familiar with it – it is used to help people use Google Earth, Google Maps and Google StreetView.
Detailed information about Googles Geocoding program can be found here:
http://code.google.com/apis/maps/documentation/javascript/v2/services.html#Geocoding_Direct
ICo3 have worked on Google Geocoding for a variety of projects – everything from search engines to estate agents websites. We’ve put together the Google Geocoding API Integration for OpenFieldWork now at:
http://www.openfieldwork.org.uk/api/member_search.php?p=&search_text=sv
This takes a series of text phrases (variations of a sample title from JorumOpen) and determines from that whether Google’s Geocoding API returns a valid coordinate.
You can actually try the Google lookup directly by putting the following into your browser:
http://maps.google.com/maps/geo?q=Svalbard
This will return the data in xml format. To return just the coordinates you can also enter:
http://maps.google.com/maps/geo?q=Svalbard&output=csv
The above term returns the following xml:
{
“name”: “Svalbard”,
“Status”: {
“code”: 200,
“request”: “geocode”
},
“Placemark”: [ {
"id": "p1",
"address": "Svalbard and Jan Mayen",
"AddressDetails": {
"Accuracy" : 1,
"Country" : {
"CountryName" : "Svalbard and Jan Mayen",
"CountryNameCode" : "SJ"
}
},
"ExtendedData": {
"LatLonBox": {
"north": 84.3767980,
"south": 62.7791490,
"east": 89.2366798,
"west": -41.8961358
}
},
"Point": {
"coordinates": [ 23.6702720, 77.5536040, 0 ]
}
} ]
}
We can then use those coordinates to place the returned string on a Google map – as can be seen in our example page:
http://www.openfieldwork.org.uk/api/member_search.php?p=&search_text=Sv&t=n
At the moment we have identified that this search will only return co-ordinates if the search finds all the phrases in the search – rogue words result in a failure. Some searches will also return business names and map them accordingly and that could produce some strange results if they hit.
There would a a solution and that would be to try all the words in the search phrase and attempt to map them. This will effectively do the following:
The Cryosphere : Svalbard Virtual fieldclass
Search The: 0,0
Search Cryosphere: 0,0
Search Svalbard: 23.6702720, 77.5536040
Search Virtual: 0,0
Search fieldclass: 0,0
In this way the program will do five searches and identify the Svalbard word as the correct code.
Taking a large range of characters it would be possible to split up and then count words used in a article – and from that identify the most common words found. Then sort those words and lookup location data for each of them.
For the next entry I will look at a range of examples where the Google Geocoding API has been used to scrape data and look for ways to extract further location specific data.