SPARQL geo function syntax

Hello,

I’ve started exploring Stardog’s geospatial features and came across this SPARQL syntax that I did not recognize:

prefix : <http://community.stardog.com/examples/>
prefix wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix qudt: <http://qudt.org/vocab/unit#>
select ?feature ?name {
    ?feature geof:nearby ( [rdfs:label "White House"] 2 qudt:MileUSStatute) ;
        rdfs:label ?name .
}

The part that was new to me was the function argument inside the square brackets: [rdfs:label "White House"]. After playing around, I learned that it seemed to behave like some kind of subquery and that I could simply replace this with an named individual instead, e.g. <tag:foo:bar>. As a programmer used to strongly typed function arguments, this blew my mind. Is my understanding correct?

I’m just looking for a better understanding of the square bracket syntax. As usual thanks for your insights!

-Peter

Hi,

The square brackets indicate a blank node. It essentially signifies here that we don't particularly care what the subject is, so long as it has an rdfs:label of "White House." You are absolutely correct that you could replace it with a named individual:

select ?feature ?name {
    ?feature geof:nearby ( :WhiteHouse 2 qudt:MileUSStatute) ;
        rdfs:label ?name .
}

...or with a variable:

select ?feature ?name {
    ?whiteHouse rdfs:label "White House" .
    ?feature geof:nearby ( ?whiteHouse 2 qudt:MileUSStatute) ;
        rdfs:label ?name .
}
1 Like

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