Stardog Support for Geospatial Function NearBy

Hi There,

I have uploaded a small ttl file using the following command (I am working with stardog 5.0.2-beta):

stardog-admin db create -n myDb -o spatial.enabled=true – dbpedia_test.ttl

myFile is as follows:

@prefix geo: <http://www.opengis.net/ont/geosparql#>.
@prefix dbr: xxx
dbr:Bord_Gáis_Energy_Theatre geo:hasGeometry _:b34949384 .
_:b34949384 geo:asWKT "POINT(53.3442497253418 -6.240039825439453)"^^geo:wktLiteral .

I now want to run Nearby:

PREFIX geos: xxx
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: xxx

SELECT * WHERE{
  ?loc geos:hasGeometry ?feature .
  ?feature geof:nearby(53.3442497253418 -6.240039825439453 2 <http://qudt.org/vocab/unit#Kilometer>).
}

I am about 95 percent sure this worked for me before, but now it does not appear to be returning anything.

Any idea what I am missing here?

Kind regards,

Kris.

Hi All,

Just so you know, I can run this by using the geometry returned, so:

SELECT * WHERE{
  ?loc geos:hasGeometry ?geo .
  ?feature geof:nearby(?geo 2 <http://qudt.org/vocab/unit#Kilometer>).
}

But, I was sure I had a nearby working using a lat and long variable as a parameter. Similar to this - Apache Jena - Spatial searches with SPARQL

Kind regards,

Kris.

To add to above comments. I want to search across two graphs using nearby.

Since I am unable to do a nearby search for geometries by given a lat and long I tried the following query:

SELECT * WHERE{
  ?loc geos:hasGeometry ?geo .
  ?geo geos:asWKT "POINT(53.3442497253418 -6.240039825439453)"^^geos:wktLiteral.
  ?feature geof:nearby (?geo 1 <http://qudt.org/vocab/unit#Kilometer>) .
}

I want to return all geometries nearby the one specified. I know I have multiple geometries from another graph in the database (I can return them). But when I run this query, I only return the one geometry with that WKT value.

I imagine I am doing something wrong which is obvious?

Any help much appreciated!

Thanks,

Kris.

Hi Kris, apologies for the late reply, but I myself was having trouble figuring out what you needed to do.

It turns out that (for the first post at least), you are doing something wrong, it’s just painfully NOT obvious. When defining a POINT as a wktLiteral, the parameters are reversed. It’s actually POINT(long lat)…but then geof:nearby expects (lat long …)

This explains why specifying the POINT again is working, but not the individual values. It also explains why using the geometry itself is also fine. If you flip them around in your query, you will see the desired results:

(Given POINT(53.3442497253418 -6.240039825439453) and POINT(long lat))

SELECT * WHERE{
?loc geos:hasGeometry ?feature .
?feature geof:nearby(-6.24003982543 53.344249725 2 <http://qudt.org/vocab/unit#Kilometer>).
}

+---------------------------------+------------------------------------------------+
|               loc               |                    feature                     |
+---------------------------------+------------------------------------------------+
| urn:dbrBord_Gáis_Energy_Theatre | _:bnode_7eaa8cb1_4c61_43ee_b72d_20fad59d8f1c_2 |
+---------------------------------+------------------------------------------------+

And as for the query spanning multiple graphs, you will either need to add a GRAPH <urn:whatever> {} block to your query, or ensure that query.all.graphs=true is specified in your stardog.properties file

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.