Tutorial XI:
SPARQL Geo Spatials and Geography PivotViewer Examples

OpenLink Software

Live Instances

All the queries in this tutorial can be verified against http://lod.openlinksw.com (LOD Cloud Cache) instance.

Also available are /sparql (basic SPARQL Endpoint) and /HtmlPivotViewer (HtmlPivotViewer Endpoint).

Geo SPARQL Geometry: Box query

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Box

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "BOX(0.3412 43.5141, 9.3412 48.0141)"
         ),
         ?p
       )
     )
    FILTER (lang(?name) = "en")
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Box: Query Result

Geo SPARQL Geometry Box

Geo SPARQL Geometry: Polygon query

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Polygon

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "POLYGON((1 2, 6 1, 9 3, 8 5, 3 6, 1 2))"
         ),
         ?p
       )
     )
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Polygon: Query Result

Geo SPARQL Geometry Polygon

Geo SPARQL Geometry: Polygon with hole query

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Polygon with hole

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "POLYGON((1 2, 6 1, 9 3, 8 5, 3 6, 1 2), (3 3, 5 5, 6 2, 3 3))"
         ),
         ?p
       )
     )
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Polygon with hole: Query Result

Geo SPARQL Geometry Polygon with hole

Geo SPARQL Geometry: Multi Polygon

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Multi Polygon

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "MULTIPOLYGON(((1 2, 6 1, 9 3, 3 6, 1 2)), ((4 9, 7 6, 9 8, 4 9)))"
         ),
         ?p
       )
     )
    FILTER (lang(?name) = "en")
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Multi Polygon: Query Result

Geo SPARQL Geometry Multi Polygon

Geo SPARQL Geometry: Geometry Collection

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Geometry Collection

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "GEOMETRYCOLLECTION( POINT(4 5), POINT(7 4), POINT(6 2), Line String(4 5, 6 7, 7 4, 6 2), Polygon((1 2, 6 1, 9 3, 8 5, 3 6, 1 2)) )"
         ),
         ?p
       )
     )
    FILTER (lang(?name) = "en")
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Geometry Collection: Query Result

Geo SPARQL Geometry Geometry Collection

Geo SPARQL Geometry: Multi Point

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Multi Point

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "MULTIPOINT(3 7, 4 2, 8 6)"
         ),
         ?p
       )
     )
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Multi Point: Query Result

Geo SPARQL Geometry Multi Point

Geo SPARQL Geometry: Line String

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Line String

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "LINESTRING(1 2, 3 6, 9 4)"
         ),
         ?p
       )
     )
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Line String: Query Result

Geo SPARQL Geometry Line String

Geo SPARQL Geometry: Multi Line String

## Find items of each type
## whose coordinates fall within a bounded
## Geometry box shape: Multi Line String

SELECT ?href
       ?name
       ?name as ?Label
       ?f
       ?type
       ?latitude
       ?longitude
FROM <http://linkedgeodata.org>
WHERE
  {
    ?href <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  ?f ;
          <http://www.w3.org/2000/01/rdf-schema#label>       ?name ;
          <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> ?p ;
          geo:lat ?latitude ;
          geo:long ?longitude .
    ?f <http://www.w3.org/2000/01/rdf-schema#label> ?type .
    FILTER
     (
      bif:st_intersects
       (
        bif:st_geomfromtext
         (
          "MULTILINESTRING((1 8, 4 4), (4 9, 8 5, 6 2, 1 4))"
         ),
         ?p
       )
     )
    FILTER (lang(?name) = "en")
  }
LIMIT 1500

## See LOD Cloud /sparql Endpoint live results.
## See LOD Cloud Pivot Viewer live results.

Geo SPARQL Geometry Multi Line String: Query Result

Geo SPARQL Geometry Multi Line String
RDF
SPARQL
SQL
OpenLink
SIOC
WG
SPARUL
ARQ
XQuery
XPath
URI
Vocabulary
IFP
RIF
RDFS
OWL
RDBMS
ODBC
JDBC
GET
POST
QL