Unveiling Geospatial Insights: Exploring Turtle (TTL) Files in RDF

Resource Description Framework (RDF) serves as a foundational standard for representing and exchanging data on the web. At the heart of RDF is the ability to describe resources and their relationships in a machine-readable format. This article delves into the exploration of Turtle (TTL) files within the GeoPlatform, shedding light on their significance in the context of geospatial datasets.

Understanding Turtle (TTL) Files

Turtle files, with their human-readable syntax, act as a means to concisely represent RDF data. The provided Turtle file in this exploration encapsulates triples describing housing developments within GeoPlatform, contributing to a more interconnected and dynamic representation of geospatial information.

Structure of the TTL File

Let’s take a glimpse into the structure of the TTL file, focusing on two datasets within GeoPlatform.

Housing Development Dataset:

PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX mads: <http://www.loc.gov/mads/rdf/v1#>
PREFIX units: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX hmulti: <https://geoapi.geoplatform.gov/collections/961ff362_5b63_4aa7_aac5_2b7bdeec906c/items/>
PREFIX hdev: <https://geoapi.geoplatform.gov/collections/883b43a4_65af_4458_899a_347b9ffa34d0/items/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX gn: <http://www.geonames.org/ontology#>
PREFIX gp: <http://www.geoplatform.gov/ns#>
PREFIX building: <http://ontology.eil.utoronto.ca/icity/Building/>
PREFIX spatialloc: <http://ontology.eil.utoronto.ca/icity/SpatialLoc>
PREFIX gci-foundation-v2-owl: <http://ontology.eil.utoronto.ca/GCI/Foundation/GCI-Foundation-v2.owl>
SELECT DISTINCT *
WHERE {
 ?item a gp:HousingMulti ;
    dcterms:identifier ?ogc_fid ;
    rdfs:seeAlso ?property_id ;
    rdfs:label ?property_name_text ;
    geo:lat ?lat ;
    geo:long ?lon ;
    mads:county ?cnty_nm2kx ;
    mads:city ?std_city ;
    geosparql:asWKT ?wkt ;
    building:locatedOn ?address_line1_text ;
    spatialloc:hasLocation ?placed_based_city_name_text ;
    building:hasUnitSize ?units1 .
FILTER(?item = hmulti:1) .
}
LIMIT 5

Housing Multifamily Dataset:

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX mads: <http://www.loc.gov/mads/rdf/v1#>
PREFIX units: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX hmulti: <https://geoapi.geoplatform.gov/collections/961ff362_5b63_4aa7_aac5_2b7bdeec906c/items/>
PREFIX hdev: <https://geoapi.geoplatform.gov/collections/883b43a4_65af_4458_899a_347b9ffa34d0/items/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX gn: <http://www.geonames.org/ontology#>
PREFIX gp: <http://www.geoplatform.gov/ns#>
PREFIX building: <http://ontology.eil.utoronto.ca/icity/Building/>
PREFIX spatialloc: <http://ontology.eil.utoronto.ca/icity/SpatialLoc>
PREFIX gci-foundation-v2-owl: <http://ontology.eil.utoronto.ca/GCI/Foundation/GCI-Foundation-v2.owl>
SELECT DISTINCT *
WHERE {
 ?item a gp:HousingMulti ;
    dcterms:identifier ?ogc_fid ;
    rdfs:seeAlso ?property_id ;
    rdfs:label ?property_name_text ;
    geo:lat ?lat ;
    geo:long ?lon ;
    mads:county ?cnty_nm2kx ;
    mads:city ?std_city ;
    geosparql:asWKT ?wkt ;
    building:locatedOn ?address_line1_text ;
    spatialloc:hasLocation ?placed_based_city_name_text ;
    building:hasUnitSize ?units1 .
FILTER(?item = hmulti:1) .
}
LIMIT 5

Spatial Queries

Once mapped, we can make queries against external data to make connections between them. For example, this query shows the power of using geospatial connections to find relevant data that would otherwise be difficult to join between relational databases.

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX gp: <http://www.geoplatform.gov/ns#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX hdev: <https://geoapi.geoplatform.gov/collections/883b43a4_65af_4458_899a_347b9ffa34d0/items/>
SELECT DISTINCT ?gpitem ?hdevName ?hdevLoc ?item ?name ?kwgwkt
WHERE {
  #GeoPlatform stand in
    SERVICE <https://c0c5-71-218-150-139.ngrok-free.app/sparql> {
    SELECT ?gpitem ?hdevName ?lat ?lon
    WHERE {
      ?gpitem a gp:HousingDev ;
         rdfs:label ?hdevName ;
         geo:lat ?lat ;
          geosparql:asWKT ?wkt ;
    geo:long ?lon .
    }
  }
  BIND(STRDT(CONCAT("<http://www.opengis.net/def/crs/OGC/1.3/CRS84> POINT(", str(?lon), " ", str(?lat), ")"), geosparql:wktLiteral) AS ?hdevLoc)
  ?item a kwg-ont:MTBSWildfire ;
     kwg-ont:hasFireName ?name ;
     geosparql:hasGeometry ?geom .
  ?geom geosparql:asWKT ?kwgwkt .
  #Alabama state Polygon retrieved from https://gist.github.com/JoshuaCarroll/49630cbeeb254a49986e939a26672e9c
  BIND("<http://www.opengis.net/def/crs/OGC/1.3/CRS84> POLYGON((-88.1955 35.0041,-85.6068 34.9918,-85.1756 32.8404,-84.8927 32.2593,-85.0342 32.1535,-85.1358 31.7947,-85.0438 31.5200,-85.0836 31.3384,-85.1070 31.2093,-84.9944 31.0023,-87.6009 30.9953,-87.5926 30.9423,-87.6256 30.8539,-87.4072 30.6745,-87.3688 30.4404,-87.5240 30.1463,-88.3864 30.1546,-88.4743 31.8939,-88.1021 34.8938,-88.1721 34.9479,-88.1461 34.9107,-88.1955 35.0041))"^^geosparql:wktLiteral as ?targetwkt) .
  FILTER(?gpitem = hdev:1) .
  FILTER(geof:sfContains(?targetwkt, ?kwgwkt)) .
  FILTER(geof:sfContains(?targetwkt, ?hdevLoc)) .
  FILTER(geof:sfContains(?kwgwkt, ?hdevLoc)) .
}
LIMIT 1

Leveraging RDF for GeoPlatform.gov

GeoPlatform.gov, in its pursuit of making Federal Geospatial FAIR, harnesses the power of RDF data to enhance accessibility and usability. RDF enables the modeling of complex spatial relationships, facilitating the integration and sharing of geographic data across diverse applications. Through RDF, GeoPlatform.gov creates a more interconnected and dynamic geospatial environment, fostering collaboration and improving the overall effectiveness of geospatial data management and analysis.

Explore early use cases using the SPARQL service at https://sparql.geoplatform.gov/.

Key Components of the TTL File

  1. Namespace Prefixes:

    • @prefix statements introduce namespace prefixes, such as schema:, dcterms:, and geo:, providing shorthand notations for longer URIs.

  2. Triple Patterns:

    • Triples follow a subject-predicate-object structure, describing aspects of housing developments in GeoPlatform.

  3. Variables and Filtering:

    • Variables like ?item, ?ogc_fid, and ?lat are employed, with filtering conditions specified to narrow down results.

Relationship to RDF Data

While the TTL file encapsulates the structure and characteristics of housing development data, the actual RDF dataset is assumed to be external, residing within GeoPlatform’s infrastructure.

Conclusion

Turtle files serve as a bridge between human readability and structured RDF data, providing a gateway for insightful queries and exploration of housing developments within the GeoPlatform ecosystem. The utilization of RDF by GeoPlatform.gov enhances the overall accessibility and usability of geospatial information, contributing to a more interconnected and collaborative geospatial landscape.

Discover more about GeoPlatform’s RDF and TTL files at https://sparql.geoplatform.gov/.