Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OpenRefine *Templating* export format template to generate a geojson file containing a lists of points and connections between them.

This OpenRefine Templating export format template will generate a geojson file containing a lists of points and connections between them.

Requires:

  • the name of the column containing the from marker description (from in the example);
  • the name of the column containing the to marker description (to in the example);
  • a column containing numerical latitude co-ordinate value for the from location (from_lat in the example);
  • a column containing numerical longitude co-ordinate value for the from location (from_lon in the example);
  • a column containing numerical latitude co-ordinate value for the to location (to_lat in the example);
  • a column containing numerical longitude co-ordinate value for the to location (to_lon in the example).

Lines are created between from/to locations specified on the same line.

Example data:

from,to,from_lon,from_lat,to_lon,to_lat
"London, UK","Cambridge, UK",-0.1276597, 51.5072759, 0.124862, 52.2033051
"Cambridge, UK", "Paris, France", 0.124862, 52.2033051, 2.3521334, 48.8565056

Note that a marker is added each time a place name is encountered.

{"features": [
{"geometry":
{ "coordinates": [ {{cells["from_lon"].value}},
{{cells["from_lat"].value}}
],
"type": "Point"},
"id": {{jsonize(cells["from"].value)}},
"properties": {}, "type": "Feature"
},
{"geometry":
{ "coordinates": [ {{cells["to_lon"].value}},
{{cells["to_lat"].value}}
],
"type": "Point"},
"id": {{jsonize(cells["to"].value)}},
"properties": {}, "type": "Feature"
},
{"geometry": {"coordinates":
[[{{cells["from_lon"].value}}, {{cells["from_lat"].value}}],
[{{cells["to_lon"].value}}, {{cells["to_lat"].value}}]],
"type": "LineString"},
"id": null, "properties": {}, "type": "Feature"}
], "type": "FeatureCollection"}
@gilsonsilvati

This comment has been minimized.

Copy link

@gilsonsilvati gilsonsilvati commented Jul 4, 2014

Show...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment