Using geo in Concept Similarity

We are using concept similarity with our data. However, I am wondering whether it is possible to use geosparql as well. I created a model and added it to Stardog. I also created a select query to use the model, which is working fine. I tried to add:

?object http://vocab.netage.nl/kro#hasLocation ?loc .
?loc http://www.opengis.net/ont/geosparql#asWKT ?wkt .
?wkt geof:nearby (?object 1 http://qudt.org/vocab/unit#Kilometer).

To the query. But the returning results have a confidence score of: NaN. Which I think means the model cannot handle geo sparql. Am I right and there be a way of adding geosparql in the selection (or do I need to add it to the insert-model creation as well)?

The use case consists of building in a city. The model is based on various features of the buildings. By adding geo sparql the idea is that I find the most similar buildings within 1 km of the selected building. At this moment I find the most similar building within the complete dataset (the complete city).

There's no inherent limitation preventing this. Are you adding the GeoSPARQL constraints to the input for concept index search or constraining the output? Are you able to share your entire query? Plans with and without GeoSPARQL would be helpful too.

Jess

I am constraining the output. Nothing is added to the input for concept index search.

The working query without GeoSPARQL:

prefix spa: tag:stardog:api:analytics:
prefix : http://schema.org/
prefix geof: http://www.opengis.net/def/function/geosparql/

SELECT ?similarObject ?confidence
WHERE { graph spa:model {
http://schema.org/building spa:arguments (?oorspronkelijkBouwjaar2 ?oppervlakte2 ?functie2);
spa:confidence ?confidence ;
spa:parameters [ spa:limit 10 ] ;
spa:predict ?similarObject ;}
{ SELECT
(spa:set(?oorspronkelijkBouwjaar) as ?oorspronkelijkBouwjaar2) (spa:set(?oppervlakte) as ?oppervlakte2) (spa:set(?functie) as ?functie2) ?object { GRAPH http://data.resc.info/kro {?object http://vocab.netage.nl/kro#hasBuildingPart ?hasBuildingPart.
?hasBuildingPart http://bag.basisregistraties.overheid.nl/def/bag#oppervlakte ?oppervlakte.
?hasBuildingPart http://vocab.netage.nl/kro#functie ?functie.
?object http://vocab.netage.nl/kro#hasBuilding ?hasBuilding.
?hasBuilding http://bag.basisregistraties.overheid.nl/def/bag#oorspronkelijkBouwjaar ?oorspronkelijkBouwjaar.
VALUES ?object {http://rescinfo.brandweeramsterdam.nl/data/kro/vraa/object/0363010000583657}}} GROUP BY ?object}} ORDER BY DESC(?confidence)

The SPARQL query with GeoSPARQL:

prefix spa: tag:stardog:api:analytics:
prefix : http://schema.org/
prefix geof: http://www.opengis.net/def/function/geosparql/
SELECT ?similarObject ?confidence
WHERE { graph spa:model {
http://schema.org/building spa:arguments (?oorspronkelijkBouwjaar2 ?oppervlakte2 ?functie2);
spa:confidence ?confidence ;
spa:parameters [ spa:limit 10 ] ;
spa:predict ?similarObject ;}
{ SELECT
(spa:set(?oorspronkelijkBouwjaar) as ?oorspronkelijkBouwjaar2) (spa:set(?oppervlakte) as ?oppervlakte2) (spa:set(?functie) as ?functie2) ?object { GRAPH http://data.resc.info/kro {?object http://vocab.netage.nl/kro#hasBuildingPart ?hasBuildingPart.
?hasBuildingPart http://bag.basisregistraties.overheid.nl/def/bag#oppervlakte ?oppervlakte.
?hasBuildingPart http://vocab.netage.nl/kro#functie ?functie.
?object http://vocab.netage.nl/kro#hasBuilding ?hasBuilding.
?hasBuilding http://bag.basisregistraties.overheid.nl/def/bag#oorspronkelijkBouwjaar ?oorspronkelijkBouwjaar.
?object http://vocab.netage.nl/kro#hasLocation ?loc .
?loc http://www.opengis.net/ont/geosparql#asWKT ?wkt .
?wkt geof:nearby (?object 2 http://qudt.org/vocab/unit#Kilometer).
VALUES ?object {http://rescinfo.brandweeramsterdam.nl/data/kro/vraa/object/0363010000583657}}} GROUP BY ?object}} ORDER BY DESC(?confidence)

When using GeoSPARQL, are you getting any results if you remove the graph spa:model block? Ie, is there any input data for the similarity index search? Can you share the query plans for both queries?

This pattern doesn't seem to make sense:

?object http://vocab.netage.nl/kro#hasLocation ?loc .
?loc http://www.opengis.net/ont/geosparql#asWKT ?wkt .
?wkt geof:nearby (?object 2 http://qudt.org/vocab/unit#Kilometer).

First, it looks like ?loc should be used instead of ?object as the first argument to geof:nearby. ?loc is the subject of the asWKT triple which is entered in the geospatial index, not ?object.

Second, even if ?object worked here, you're using ?wkt which is the location of object to test if the object is within two kilometers of itself which is trivially true.

Hope this helps.
Jess

I see, I changed the object with coordinates and still have the same output:

?object http://vocab.netage.nl/kro#hasLocation ?loc .
?loc geof:nearby (52.3309521629772 4.98460929863151 2 http://qudt.org/vocab/unit#Kilometer).

I tested this geosparql query separate from the similarity search query and it work.

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