Re: SPARQL & SemWeb

On Apr 16, 2006, at 8:53 AM, Christopher Schmidt wrote:

>> Another interesting query would be "Give me all pictures I took in  
>> city X".
>> In order to solve this puzzle, one would have to know the exact  
>> spatial data
>> of city X (a bounding rectangle would not be enough) and be able  
>> to pinpoint
>> Lat/Lon within that range, using a RDF-querylanguage... I think  
>> that's a
>> hard one to answer for.
>
> In this case, again, you'd take your post-processing solution.  
> However,
> I think that conflating semweb/GIS databases is a bad idea. Instead,
> what I would personally do is take each geo:Point in my crawled
> database, store it in a PostGIS database with either the URL or bnode
> identifier. You can then submit queries against the PostGIS  
> database for
> lat/long queries, and then look up the data in the RDF datastore  
> for the
> actual content that you want.

Strangely enough, I've been working on exactly this during the past  
week. I've been working on a patch to RDF::Query (perl sparql  
implementation) that would allow spatial operators to be used in a  
SPARQL FILTER, and have those queries be directly translated into  
queries for a PostGIS database containing both the RDF data (using  
Redland's PostgreSQL schema) and geographic data (maintained by  
triggers on the RDF data). I haven't got much working at this stage,  
but I agree that this is quite an interesting area to be looking into.

As for querying photos based on city, I've found it easiest to spend  
the time pre-processing the photo data during import to add the city  
names ahead of time. In this way, I'm able to query photos with  
something like this:

SELECT ?place ?img
WHERE {
	?img a foaf:Image ; dcterms:spatial [ a geo:Point ; cyc:inRegion  
[ foaf:name "Boston, MA" ] ] .
}

This pre-processing is very easy using something like PostGIS for  
areas where good spatial data is available (Tiger/LINE and the  
USCensus ZIP Code Tabulation Area data sets come to mind), but I've  
had to resort to a "name of the closest known point" strategy for  
photos outside of these areas.

hope that helps,
.greg

-- 
"Writing code on one line is like playing
  the trumpet without breathing!"
     - Adam Pisoni

Received on Sunday, 16 April 2006 15:48:34 UTC