Reputation: 311
I am working on GEOSPARQL queries. And I want to store Polygon Coordinates as wktLiteral values using RDF Graph (RDFLIB python). Currently I am doing that using the below code.
GEO = Namespace("http://www.opengis.net/ont/geosparql#")
if name == "wkt":
self._graph.add((image, GEO["asWKT"], rl.Literal(value, datatype=GEO.wktGeneral)))
But when I see results in my Apache Fuseki server. I am not able to see proper datatype for "POLYGON(()) coordinates". Please let me know if anything is missing. Thank you.
Upvotes: 0
Views: 720
Reputation: 1251
Try this code:
from rdflib import Graph, Literal, URIRef, Namespace
GEO = Namespace("http://www.opengis.net/ont/geosparql#")
g = Graph()
g.bind("geo", GEO)
x = URIRef("x:")
g.add((x, GEO["asWKT"], Literal("value", datatype=GEO.wktLiteral)))
print(g.serialize(format="turtle").decode("utf-8"))
This returns the datatype just fine.
wktLiteral
, not wktGeneral
Literal()
directly, not rl.Literal()
There may be other things but you've not presented enough code for me to tell.
Upvotes: 0