Skip to content

ogcincubator/topo-functions

Repository files navigation

topo-rdf-geojson

Reads an RDF Turtle topology model (geojson-topo vocabulary) and returns a dict of GeoJSON geometry objects for every feature, indexed by both full URI string and qname (prefix:local).

Installation

pip install topo-rdf-geojson

Usage

from topo_rdf_geojson import load_topo

geometries = load_topo("path/to/model.ttl")

# index by full URI
geom = geometries["http://csdm-example-surveys/DP-572532/8446454"]

# index by qname when a matching prefix is declared
geom = geometries["eg2:8446454"]

print(geom)
# {"type": "Polygon", "coordinates": [[[lon, lat], ...]]}

CLI

topo-rdf-geojson <source.ttl> [--key URI_OR_QNAME] [--keys-only] [--indent N]
Option Description
--key Return geometry for a single feature (URI or qname)
--keys-only Print only the index keys
--indent N JSON indent level (default 2)

Supported topology types

RDF type GeoJSON output
Point / geojson:geometry Point
Edge / geojson:LineString LineString
Ring Polygon (single ring)
Face Polygon (multiple rings)
Shell MultiPolygon
Solid MultiPolygon (union of all faces)
geojson:Polygon Polygon (edges auto-chained by adjacency)

Multiple geojson:topology triples on the same feature are merged: all LineStrings → MultiLineString, all Polygons → MultiPolygon, mixed → GeometryCollection.

Dependencies

About

Python module with functions for manipulating 3D topology objects using the topo-feature model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages