🚀 Refactored from Deno to Go as part of my ongoing learning!
This version can process more of the dataset in less time (Apple M1: Deno - 98 sec, Go - 34 sec).
Ordnance Survey (OS) Open Names is a comprehensive dataset of place names, roads numbers and postcodes for Great Britain. It's an OGL dataset provided in the British National Grid EPSG:27700
CRS.
This code converts the OS Open Names CSV dataset into a JSON array consisting of multiple GeoJSON Features. It's designed for bulk importing into MongoDB using MongoDB Compass. The bulk importer expects a JSON array of features, not a GeoJSON object - and therefore this script won't create a valid GeoJSON file.
The following metadata is included by default: id
, type
, localType
, name1
, name1Lang
, name2
, name2Lang
, geomX
, geomY
. Geometry is converted to lat-lon
values, and the name2
and name2Lang
are often empty strings.
I'm not creating prebuilt binaries for this script at this time.
-
Install Go on your machine. I do this via Homebrew on MacOS.
-
Copy the
/Data
directory from OS Open Names into the root of this repository. This directory contains ~819 CSV files each representing a distinct region. -
Run the script with
go run main.go
. The output is stored in a newly createdoutput.json
file.
If you choose to host this dataset with MongoDB you must create a 2dsphere
index to handle geospatial queries. I also strongly advise creating indexes for any other columns you plan to query against.
MIT License. Feel free to refactor to suit your needs.
This script relies on the awesome wroge/wgs84 and paulmach/orb packages for coordinate transformation and GeoJSON parsing.