Re: SPARQL GEO and SQL GIS extensions

For those of you working with ARQ, I have some related
experimentation using ARQ 2.5 and an open source RTree
index.  The index is built by first looking at the
graph and storing the URI's into an RTree structure
based on the node's latitude and longitude
(wgs84_pos).  I used LARQ (a lucene index extension)
as a model and adapted the pattern for spatial
indexing.

geo:nearby(lat lon limit), used in an example query...

PREFIX : <http://example.org/>
PREFIX geo: <java:org.geospatialweb.arqext.
SELECT ?n WHERE { ?s geo:nearby(51.45 -2.5833333 30) .
?s a :Hotel . ?s :name ?n }

nearby() will reduce the graph down to a limited set
of nodes that are "nearest" the given latitude and
longitude, after which you can further restrict the
results, in this example we're looking for only
hotels, and then binding the name to ?n.  To run the
extension you'll need to be familiar with running ARQ
in a java dev environment.  The advantage of the RTree
is that we're not just filtering the RDF, we're
quickly getting  a subset of the graph that is nearest
to our target.  It also supports a bounding  box style
query:

geo:within(lat lon lat2 lon2) 
(lower corner first, then upper corner)


http://geospatialweb.googlecode.com/svn/trunk/jenaext/dist/geospatial-0.0.1.jar

Here's an example of using the functions on a geonames
dump of GB:
http://geospatialweb.googlecode.com/svn/trunk/jenaext/example/ex/Main.java

Data set:
http://geospatialweb.googlecode.com/svn/trunk/jenaext/GB.txt

Extension functions jar (at a minimum you'd need to
add this to your ARQ distribution to run the example):
http://geospatialweb.googlecode.com/svn/trunk/jenaext/dist/geospatial-0.0.1.jar

The ARQ extension implementation is there in the trunk
as well:
http://geospatialweb.googlecode.com/svn/trunk/jenaext/src/org/geospatialweb/arqext/

Notice the index itself is built by first running a
SPARQL query to select candidate nodes:

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?s ?lat ?lon
WHERE {?s geo:lat ?lat . ?s geo:long ?lon}

So hypothetically, you could make some small changes
and have the index built upon any ontology that has a
lat/lon value.

Taylor



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Received on Monday, 4 February 2008 22:00:45 UTC