开发者

Wikipedia API for geolocations

Is it possible, using the existing Wikipedia API's to get a list of articles around a Geo-location? Sort of like how Google maps does it?

I would like to say that I am "here" and find out what is around me on Wikipedia.

I can see on articles like this you can see the "Coordinates" on the right hand side, so I would like to do a query on t开发者_高级运维hese coordinates...

any thoughts?


UPDATED ANSWER:
Wikilocation has been retired and now there is an OFFICIAL WIKIPEDIA API

? action=query
& list=geosearch
& gsradius=<radius-in-meters>
& gscoord=<lat>|<lon>

HTML example | JSON Example


Don't reinvent the wheel, use DBpedia.
Sample page with "lat" and "lon" data extracted.
And it can be queried with SPARQL.


Have a look at Wikilocation, might be useful.


This is nowadays built into Wikipedia through Special:Nearby.

https://en.wikipedia.org/wiki/Special:Nearby


It seems like there is no Wikipedia API for this, but this Wikipedia page describes how others make use of this information:

All coordinates are available for download in Wikipedia database dumps. To get the coordinates from the XML format dump of all articles (enwiki-latest-pages-articles.xml.bz2, 4 GB), the dump needs to be parsed for pages containing coordinates in the entry formats listed above. Most articles in Wikipedia conform to these formats and coordinates are easy to parse from the wikitext with regular expressions for simple character sequences. As all coordinates link to the same PHP tool, they may also be found from the SQL format table of external links (enwiki-latest-externallinks.sql.gz, 725MB). This second method will however not include all available information about the coordinates, such as their position between the article body and the title area.


Solution jquery and geonames API:

a,b = longitude, latitude, tweet -> html div

function getcontent(a,b) {
    jQuery(function($) {
        $.getJSON('http://api.geonames.org/findNearbyWikipediaJSON?formatted=true&lat='+ a +'&lng='+ b +'&username=username&style=full&lang=de&wikipediaUrl&thumbnailImg', function(json) {
            for(var i = 0; i < json.geonames.length; i++) {
                $("#tweet").prepend('<span style="font-family: geneva, arial, helvetica, sans-serif;"><br><br><img src="wikilogo.gif"><br>' + json.geonames[i].summary + '<br><a href="http://'+ json.geonames[i].wikipediaUrl +'" target="_blank">'+ json.geonames[i].wikipediaUrl +'</a><br></span>');
            }
        }); 
    }); 
}


I know, this is an old question, but here is the URL format for a similar query:

https://en.wikipedia.org/w/api.php?action=query&list=geosearch&format=json&gscoord=40.418670|-3.699389&gsradius=10000&gslimit=10

after &gscoord= you should put the coordinates separated by |, and after &gsradius= the search radius in meters, gslimit is the max number of entries in response.

The response contains JSON.


DBpedia and SPARQL are not good options, at least not for the German Wikipedia: The coverage is too small.

I'm trying to parse all the different geo coordinate formats by myself right now (from the dumps), but that's quite difficult as there are really a lot of different variants.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜