Database Reference
In-Depth Information
51.5055},{"summary": "London is a city in
Southwestern Ontario, Canada, situated
along the Quebec City-Windsor Corridor.
The city has a population of 366,151
according to the 2011 Canadian census.
London is the seat of Middlesex County,
at the forks of the non-navigable Thames
River, approximately halfway between
(...)","rank": 100,
"title": "London, Ontario",...
2. AsyoucanseefromtheJSONoutputfortheGeoNamesWebservice,fora
givenquerystring(alocationname),yougetalistofWikipediapagesrelated
tothatlocationinaJSONformat.ForeachJSONobjectrepresentingaWiki-
pediapage,youcangetaccesstotheattributessuchasthe page title ,
summary , url , and the coordinates of the location.
3. Now,createatextfilenamed working/chp08/names.txt withthenames
ofplacesyouwouldliketogeocodefromtheWikipediaFullTextSearchWeb
services.Addsomeplacenames,forexample(inWindows,useatexteditor
such as Notepad):
$ vi names.txt
London
Rome
Boston
Chicago
Madrid
Paris
...
4. Nowcreateafilenamed import_places.py under working/chp08/ and
addtoitthePythonscriptofthisrecipe.Thefollowingishowthescriptshould
look(youshouldbeabletofollowitbyreadingthein-linecommentsandthe
How it works... section):
import sysimport urllib2import simplejson
as jsonfrom osgeo import ogr, osrMAXROWS
Search WWH ::




Custom Search