I’ve added the ability to store geospatial data in Dgraph when expressed in RDF.
e.g. the the location of an airport may be encoded in RDF as:
<apt.a61zr1acn7x4> <location> "{\"type\":\"Point\",\"coordinates\":[-116.2227783,43.5644455]}"^^<geo:geojson> .
Here the value is the geometry object expressed in GeoJson.
Normally when you get a GeoJson dataset, it is not expressed in a line by line format as above. But instead, it is one complete JSON file which includes the geometry information for all features. (e.g. all the airports). Hence it requires some amount of preprocessing before it can be expressed in the RDF format as above.
Moreover, the GeoJson format expresses much more than just the geometry. e.g. the above airport information is available as:
{
"type":"Feature",
"properties":{
"Total Enpl":1420073.0,
"State0":"ID",
"Landing Fa":"BOI",
"id":"a61zr1acn7x4",
"Name0":"Boise Air Terminal/Gowen Field",
"County0":"Ada County"
},
"geometry":{"type":"Point","coordinates":[-116.2227783,43.5644455]}
}
The geojson file represents a FeatureCollection
which is essentially an array of these Feature
objects. This Feature
can easily be expressed in RDF as:
<a61zr1acn7x4> <Total_Enpl> 1420073.0^^<xs:int> .
<a61zr1acn7x4> <State0> "ID" .
<a61zr1acn7x4> <Landing_Fa> "BOI" .
<a61zr1acn7x4> <Name0> "Boise Air Terminal/Gowen Field" .
<a61zr1acn7x4> <County0> "Ada County" .
<a61zr1acn7x4> <geometry> "{\"type\":\"Point\",\"coordinates\":[-116.2227783,43.5644455]}"^^<geo:geojson> .
Now, instead of having the user have to preprocess the geojson file into something that we can consume, I am wondering if we should just modify the loader to accept the geojson file type and then convert it directly to NQuads as I have shown above.