Stardog Geospatial SPARQL Query Example on WGS-based Data

Hi,

I am testing the geoSpatial features and manage to get it work correctly using the data + SPARQL given here:
https://groups.google.com/a/clarkparsia.com/forum/#!searchin/stardog/geospatial$20sparql/stardog/pgWQz3oCX6M/6dAmraC3FAAJ

This does work for me with GWS-based data only if there are also WKT-based data in the store. If I load only GWS-based data it does not work, maybe I just don't know how to query correctly as there will be no geo:hasGeometry in the store.

I saw in the above-mentionned post the reply from Tom Kelly, saying:

In cases when I'm not sure that my reference point (for the nearby query) is WGS or GEO, I modified the query pattern to look for the URI just by its rdfs:label:
?hq geo:hasGeometry ?hqGeo ; rdfs:label "White House"
becomes
?hq rdfs:label "White House"

but in that case, how do you change the next line as there is no more ?hqGeo variable ?

?feature geof:nearby (?hqGeo 2 http://qudt.org/vocab/unit#MileUSStatute).

Is it possible to have a geof:nearby query example for a dataset containing only WGS-based Data ?
Thank you in advance
Fabian

Hi Fabian,

You would just have to use ?hq instead of ?hqGeo in this case. Given these data:

prefix : <http://community.stardog.com/examples/>
prefix wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix geo: <http://www.opengis.net/ont/geosparql#>

:whiteHouse a :Location ;
    rdfs:label "White House" ;
    wgs:lat "38.897676"^^xsd:float ;
    wgs:long "-77.03653"^^xsd:float .

:myPoint a :Location ;
	rdfs:label "My Point" ;
	wgs:lat "38.897673"^^xsd:float ;
	wgs:long "-77.03655"^^xsd:float .

I can run this query:

prefix : <http://community.stardog.com/examples/>
prefix wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
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 {
	?wh rdfs:label "White House" .

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

Or even this more concise query:

prefix : <http://community.stardog.com/examples/>
prefix wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
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 .
}

And get these results:

+-------------+---------------+
|   feature   |     name      |
+-------------+---------------+
| :whiteHouse | "White House" |
| :myPoint    | "My Point"    |
+-------------+---------------+
1 Like

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