开发者

[SPARQL/DBPedia]make a query with a zip-code and get some information about the city

Hey, i want to make a query with a zip-code to get some informations about the City. But how it works?

Can someone tell me 开发者_开发百科how the query must look?

Greetz sheepy


I am not sure if dbpedia holds zip-code data. What they have are the geographical coordinates of all the resources that can be geographically positioned.

You could extract those coordinates with queries similar to :

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX onto: <http://dbpedia.org/ontology/> 
SELECT * WHERE {
?s a onto:Place .
?s geo:lat ?lat .
?s geo:long ?long .
} 
LIMIT 100

This query would get for you all places with their coordinates. You could use Google MAPs API to get the coordinates for certain zip-code and then get places around that zip-code by filtering the coordinates in the SPARQL query.

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX onto: <http://dbpedia.org/ontology/> 
SELECT * WHERE {
?s a onto:Place .
?s geo:lat ?lat .
?s geo:long ?long .
} FILTER ( ?long > YOUR_LONG - radius && ?long < YOUR_LONG + radius &&
lat > YOUR_LAT - radius && ?lat < YOUR_LAT + radius)
LIMIT 100

If you explain a bit more your use case I might be able to help better.

Another hint ... you could use also Geonames


Is it possbile that the FILTER has to be included into the Where brackets{}?

SELECT * WHERE { ?s a onto:Place . ?s geo:lat ?lat . ?s geo:long ?long . FILTER ( ?long > YOUR_LONG - radius && ?long < YOUR_LONG + radius && lat > YOUR_LAT - radius && ?lat < YOUR_LAT + radius) } LIMIT 100

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜