Package: geonames_rdf
IntroductionThis is a client library for theGeonamesRDF-compatibleweb-services. At this time, only theSearch APIprovides RDF responses and is, therefore, the only adapter available.RDF is often used in association with theSemantic Weband/or theIoT.RequirementsrequestsPython 2.x or 3.xInstallationVia PyPI:$ sudo pip install geonames_rdfUsageAs a library:import geonames.adapters.search

_USERNAME = 'your_username'
sa = geonames.adapters.search.Search(_USERNAME)

result = sa.query('detroit').country('us').max_rows(5).execute()
for id_, name in result.get_flat_results():
    # make_unicode() is only used here for Python version-compatibility.
    print(geonames.compat.make_unicode("[{0}]: [{1}]").format(id_, name))When used as a library, a result object will be returned from theexecute()method. The following are the ways to read the results (get_flat_resultsis used above):The rawlxmlobject is exposed through thexmlproperty.Theget_xml_nodesmethod will return a list ofFeaturelxml.etreeobjects from the resulting document, representing each of the results.Theget_flat_resultsmethod will simply yields a list of (id, name) 2-tuples if you’re not interested in anything else. This is also what’s returned, by default, from the command-line utility.As a command-line utility:$ gn_search dsoprea -p query detroit -p country us -p max_rows 5
[http://sws.geonames.org/4990729/]: [Detroit]
[http://sws.geonames.org/6955112/]: [Detroit-Warren-Livonia]
[http://sws.geonames.org/5024238/]: [Detroit Lakes Airport]
[http://sws.geonames.org/4990733/]: [Detroit City Airport]
[http://sws.geonames.org/4990742/]: [Detroit Metropolitan Wayne County Airport]You may only provide string (non-boolean) parameters to the command-line utility.NOTE:You can also get the complete RDF response by passing the “-x” parameter.Whether you’re using the library or the tool, the parameters that are available are:Library Parameter NameAPI Parameter Namequeryqplace_name_likenameplace_name_equalsname_equalsplace_name_starts_withname_startsWithmax_rowsmaxRowsstart_rowstartRowcountrycountryshow_country_firstcountryBiascontinentcontinentCodeadmin_code1adminCode1admin_code2adminCode2admin_code3adminCode3feature_classfeatureClassfeature_codefeatureCodepopulation_classcitieslanguagelangverbositystyleforce_matching_nameisNameRequiredtagtagoperatoroperatorcharsetcharsetfuzzyfuzzyeast_west_north_south_boxeast,west,north,southplace_name_languagesearchlangorder_byorderbySome of the parameters can be specified more than once. See the API documentation for more information.Design NotesNote that most of the parameters in the library are named differently from the API. Normally this goes against my policy, but I found so many of the parameters to be ambiguous or cryptic that I renamed those parameters to be clearer and just renamed the rest to underscore-separated naming while I was at it.We mostly rely on the API to correctly validate against bad parameters. We don’t like arbitrarily validating parameters in the client since the rules may change in the server and it’s one more thing that might interfere with your implementation. However, if there is a type of validation that, for one reason or another, makes sense and/or would make things easier to develop against, let me know.