English 中文(简体)
[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

最佳回答

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

问题回答

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





相关问题
Defining cardinality for a RDF statement

Im having a problem with RDF. I have a couple of triples defined as : <User rdf:about="#T"> <hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">T</hasName> <...

Duplicate triple in RDF, authoritative view?

if a triple store contains twice the same triple, what is (if any exist) the authoritative position about this redundancy ? Additionally, should a triplestore be allowed to store twice the same ...

Pick and RDF/SPARQL

Anyone have any interest in intergrating RDF and/or SPARQL with a PICK database? Has anyone tried this yet? I have some thoughts about what to try. One idea is to figure out how to create a file with ...

Using contexts in rdflib

I am having trouble finding a clear, sensible example of usage of context with rdflib. ConjunctiveGraph does not accept contexts, and Graph is deprecated. How am I supposed to create and operate on ...

What is the difference between RDF and OWL? [closed]

I am trying to grasp the concept of Semantic Web. I am finding it hard to understand what exactly is the difference between RDF and OWL. Is OWL an extension of RDF or these two are totally different ...

Problem with SPARQLWrapper (Python)

I m making a SPARQL query against the Sesame store in localhost, using SPARQLWrapper: sparql = SPARQLWrapper( http://localhost:8080/openrdf-sesame/repositories/rep/statements ) sparql.setQuery(...

热门标签