Working with Geo-Spatial Data

Enabling GeoSPARQL

Enable GeoSPARQL and Related Features is available under the Manage tab. It specifies whether GeoSPARQL and related features are available for the collection. If enabled then all SPARQL queries issued by the editor use a spatial index for the production collection and its imports.

Building the spatial index may consume time and memory, yet geography-related queries will be significantly faster.

Map Explorer Panel

This panel works with EDG’s GeoSPARQL support. In order to use the Google Maps panels, your EDG Administrator needs to set a Google Maps API Key in the configuration parameters page. Geo location information must use W3C vocabulary for representing latitude, longitude and altitude information in the WGS84 geodetic reference datum (namespace http://www.w3.org/2003/01/geo/wgs84_pos). The W3C vocabulary has properties for specifying geo coordinates.

TopBraid EDG provides the W3C vocabulary within its own Geo vocabulary that adds additional features for controlling map display. You will find it as an option in the Settings>Includes dialog by using Other as the collection type. If you do not see it in the dialog, click on the Home button in your asset collection and in the Source Code panel add:

owl:imports <http://topbraid.org/tbgeo>;

To make geo coordinate properties directly available to your resources, you will typically declare their types as subclasses of geo:SpatialThing class. As an example, you can look at the TopBraid Example Geo Ontology in the Asset Collections Samples project where this is already done.

The Map Explorer panel will display selected resources on the map using their geo coordinates – values of geo:lat and geo:long properties.

The panel can display items using markers of different types, sizes and color. This is controlled using properties such astbgeo:fillColor. It can also display shapes (e.g., polygons) as shown below. These features require inclusion of TopBraid GeoSPARQL Vocabulary (tbgeo: namespace).

TopBraid EDG Map Explorer - Germany

TopBraid EDG Map Explorer - Germany

TopBraid EDG Map Explorer - Switzerland and Austria

TopBraid EDG Map Explorer - Switzerland and Austria

Follow the below example to get started with the polygon display.

Create an Ontology, include TopBraid GeoSPARQL Vocabulary. In the class that will contain data to display on the map (e.g. Country), use Create or Add Property> Add an existing property definition (property shape): geosparql:Feature-hasGeometry. This defines the property hasGeometry that can hold instances of geosparql:Geometry and those can carry either a GML or WKT rendering of the polygon or multi-polygon. Mark geosparql:Geometry as a public class of your ontology (click the Home button and switch to GraphQL Schema View in the Form to do this) so you will be able to readily create its instances.

Create an asset collection based on your new ontology e.g., a Data Graph. Enable GeoSPARQL support on the Manage tab, Create an instance of geosparql:Geometry class. Using the Form or the Source Code panel, enter the information in the below example. Most data of this type will probably be imported.

Example:

ex:SwissGeometry
a geosparql:Geometry ;
geosparql:asWKT "MULTIPOLYGON(((7.697223 47.543327, 8.57642 47.59137, 8.566111 47.806938, 9.566724 47.540451, 9.533569 47.274544, 9.474637 47.057457, 9.598635 47.063835, 10.471235 46.871353, 10.465277 46.546387, 10.050278 46.539993, 10.129999 46.227219, 9.28194400000012 46.495827, 9.036665 45.837776, 8.43638800000014 46.463333, 7.855742 45.919052, 7.038054 45.931938, 6.79138900000015 46.434166, 5.966666 46.209442, 6.99055500000014 47.497215, 7.588268 47.58448, 7.697223 47.543327)))"^^geosparql:wktLiteral ;
.
ex:Switzerland
geosparql:hasGeometry ex:SwissGeometry ;
tbgeo:fillColor "green" ;
tbgeo:fillOpacity 0.8 ;
tbgeo:strokeColor "blue" ;
.

An example value in GML:

geosparql:asGML """<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<gml:Polygon xmlns:gml=\"http://www.opengis.net/ont/gml\">
<gml:exterior>
<gml:LinearRing>
<gml:posList>13.833611 48.773605 14.70028 48.581379 15.025833 49.018883 16.946182 48.619064 17.166386 48.012497 17.053886 47.709442 16.450554 47.698051 16.713886 47.543884 16.510555 47.00666 16.111805 46.86972 14.544998 46.407494 13.718655 46.526611 12.440554 46.690826 12.127777 47.001663 10.471235 46.871353 9.598635 47.063835 9.533569 47.274544 9.566724 47.540451 10.173332 47.274719 10.478054 47.591942 11.095554 47.396111 12.735554 47.684166 13.016666 47.470276 12.758333 48.123886 13.833611 48.773605</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>"""^^geosparql:gmlLiteral ;

The values of tbgeo:fillColor, etc., can be dynamically computed using sh:values rules. The map will automatically update when (asserted) values for tbgeo:fillColor etc., change after edits, but this will not work for dynamically computed values.