Dumpgj: JSON-LD and CRS
The dumpgj
script installed by Fiona 0.14 is among other things a vehicle
for changing the way people think about GeoJSON.
There's a growing sense in the GeoJSON community that the crs object is over-engineered. It's rarely used, and those who do use it report that they would be just as happy with OGC URN strings instead of the existing objects. The new version of dumpgj adds an experimental:
"_crs": "urn:ogc:def:crs:OGC:1.3:CRS84"
to a feature collection when the input data is WGS84 longitude and latitude, as with Natural Earth shapefiles, and something like:
"_crs": "urn:ogc:def:crs:EPSG::3857"
for systems in the EPSG database (3857 is Spherical Mercator).
Additionally, dumpgj users can, with --use-ld-context
, add more information
to their GeoJSON files. The context object added to feature collections states
more specifically what is meant by "Feature", "properties", "geometries", etc.
Fiona's GeoJSON context looks like this:
{ "@context": { "Feature": "http://geovocab.org/spatial#Feature", "FeatureCollection": "_:n1", "GeometryCollection": "http://geovocab.org/geometry#GeometryCollection", "LineString": "http://geovocab.org/geometry#LineString", "MultiLineString": "http://geovocab.org/geometry#MultiLineString", "MultiPoint": "http://geovocab.org/geometry#MultiPoint", "MultiPolygon": "http://geovocab.org/geometry#MultiPolygon", "Point": "http://geovocab.org/geometry#Point", "Polygon": "http://geovocab.org/geometry#Polygon", "_crs": { "@id": "_:n2", "@type": "@id" }, "bbox": "http://geovocab.org/geometry#bbox", "coordinates": "_:n5", "features": "_:n3", "geometry": "http://geovocab.org/geometry#geometry", "id": "@id", "properties": "_:n4", "type": "@type" } }
I'm currently mapping GeoJSON's "id" and "type" to JSON-LD keywords, some other items to the GeoVocab spatial and geometry vocabularies, and giving the rest blank node identifiers until the GeoJSON community defines a namespace and permanent identifiers for them.
GeoJSON feature properties are the things that I think stand to benefit the
most from a JSON-LD context. If a feature has a "title" property, is that an
honorific like "Mr." or "Duchess of York"? Is it "NBA Championship"? Or
something else? The dumpgj
script has a --add-ld-context-item
option
that can be used to nail a property down a little more tightly. For
example,
adds:
"title": "http://purl.org/dc/elements/1.1/title",
to the feature collection's JSON-LD context. This is what "title" usually means in my applications.
Lastly, dumpgj
will build the entire GeoJSON object in memory by default,
but has a more economical --record-buffered
option that only builds feature
records in memory and writes them immediately to the output stream.