Skip to content

Instantly share code, notes, and snippets.

@kudarisenmon
Created January 30, 2017 08:42
Show Gist options
  • Select an option

  • Save kudarisenmon/44d034060fb5ca17920b3ff9fb33559d to your computer and use it in GitHub Desktop.

Select an option

Save kudarisenmon/44d034060fb5ca17920b3ff9fb33559d to your computer and use it in GitHub Desktop.
YOLPのJSON出力(yolp.json)をGeoJSONに変換する
"use strict";
var Obj = function(name, latlon) {
this.name = name;
this.geo = {};
this.geo.type = "Point";
this.geo.coordinates = [];
this.geo.coordinates.push(parseFloat(latlon.split(",")[0]));
this.geo.coordinates.push(parseFloat(latlon.split(",")[1]));
}
var GeoJSON = require('geojson');
var util = require('util');
var jsonfile = require('jsonfile');
var shimada = require('./yolp.json');
var data = [];
shimada.Feature.forEach(function(element, index, array) {
var obj = new Obj(element.Name, element.Geometry.Coordinates);
data.push(obj);
});
var out = GeoJSON.parse(data, {GeoJSON: 'geo'});
var json = jsonfile.writeFileSync('yolp.geojson', out, {
encoding: 'utf-8',
replacer: null,
spaces: null
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment