Created
January 28, 2016 16:49
-
-
Save tmcw/99366184c386e3aab354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name | lat | lng | |
---|---|---|---|
Tom | 42 | 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mapnik = require('mapnik'); | |
mapnik.register_default_input_plugins(); | |
var source = new mapnik.Datasource({ | |
type: 'csv', file: './csv_to_geojson.csv' | |
}); | |
// get meta-information about this datasource | |
console.log(source.describe()); | |
// convert this CSV file into GeoJSON | |
var featureset = source.featureset(); | |
var featureCollection = { type: 'FeatureCollection', features: [] }, feature; | |
while (feature = featureset.next()) { | |
featureCollection.features.push(JSON.parse(feature.toJSON())); | |
} | |
console.log(JSON.stringify(featureCollection, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mapnik-second-act", | |
"version": "1.0.0", | |
"description": "demos of useful mapnik functionality", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [ | |
"mapnik", | |
"demos" | |
], | |
"author": "Tom MacWright", | |
"license": "ISC", | |
"dependencies": { | |
"mapnik": "^3.4.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment