On Thu, Sep 12, 2013 at 3:44 PM, Iain Ritchie <[email protected]> wrote: > Hi, > > I'm running a query against some dbPedia data relating to latitude and > longitudes of cities. Some cities have multiple entries for latitude and > longitude. Is there any way that I can manage this within the SPARQL query, > for example picking the first occurrence of the city or calculating the > average of the latitude and longitudes, so that the resultant list consists > of at most one occurrence of the cities? > > SELECT DISTINCT ?place ?lat ?long WHERE { > ?place <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat. > ?place <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long. > } > > ?place ?lat ?long ?population > <http://dbpedia.org/resource/Sheffield> > "53.3836"^^<http://www.w3.org/2001/XMLSchema#float> > "-1.46694"^^<http://www.w3.org/2001/XMLSchema#float> > <http://dbpedia.org/resource/Sheffield> > "53.3836"^^<http://www.w3.org/2001/XMLSchema#float> > "-1.46667"^^<http://www.w3.org/2001/XMLSchema#float>
Someone asked a very similar question on StackOverflow, after running into the same problems. The answer there might help. In that case, the answer shows how to select, e.g., the maximum of the longitude values. http://stackoverflow.com/questions/17174439/dbpedia-sparql-query-returns-multiple-and-duplicate-records -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
