Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Created May 16, 2014 11:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychemedia/0b330801a6a3535ba924 to your computer and use it in GitHub Desktop.
Save psychemedia/0b330801a6a3535ba924 to your computer and use it in GitHub Desktop.
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
Copy link

Show...

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