Reverse wikipedia geotagging lookup

时光总嘲笑我的痴心妄想 提交于 2019-12-02 20:55:24

The OpenLink Virtuoso server used by the dbpedia endpoint has several query features. I found the information on http://docs.openlinksw.com/virtuoso/rdfsparqlgeospat.html useful for a similar problem.

I ended up with a query such as this:

SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(15.560278, 58.394167)))
WHERE{
    ?m foaf:page ?page.
    ?m geo:geometry ?geo.
    ?m geo:lat ?lat.
    ?m geo:long ?long.
    FILTER (bif:st_intersects (?geo, bif:st_point(15.560278, 58.394167), 30))
}
ORDER BY ASC 4 LIMIT 15

This example retrieves the geotagged locations within 30 km from the origin position.

You should be able to query for latitude/longitude using SPARQL and dbpedia. An example (from here):

SELECT distinct ?s ?la ?lo ?name ?country WHERE {
?s dbpedia2:latitude ?la .
?s dbpedia2:longitude ?lo .
?s dbpedia2:officialName ?name .
?s dbpedia2:country ?country .
filter (
  regex(?country, 'England|Scotland|Wales|Ireland')
  and regex(?name, '^[Aa]')
)
}

You can run your own queries here.

There are a couple of tools listed on Tools and applications based on coordinates from Wikipedia. I'm not sure if it's what you're looking for, but the Geosearch.py tool looks pretty cool.

Not an API, but you can also download this nice set of all geo-tagged wikipedia articles and query it directly in a local database: http://www.google.com/fusiontables/DataSource?dsrcid=423292

The free GeoNames.org FindNearbyWikipedia service can fetch geotagged articles for a give postal code or coordinates (latitude, longitude)

It provides 30,000 credits daily limit per application (identified by the parameter 'username'), the hourly limit is 2000 credits. A credit is a web service request hit for most services. An exception is thrown when the limit is exceeded.

I'm not familiar enough with SPARQL, but if it can use power in its filter then its easy to compute the distance of a given article from a given point using Pythagoras theorem (a^2 + b^2 = c^2) and that would give you all the articles in a radius.

Another option would be to get a Wikipedia data dump and process it yourself - this is what I did when I needed to do some linguistic analysis on Wikipedia article.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!