If you want to learn more about geoJSON, you can check the following website: http://geojson.org/
node --version
npm install fast-csv
npm install fs
npm install terraformer
npm install terraformer-wkt-parser
var csv = require('fast-csv');
var fs = require('fs');
var Terraformer = require('terraformer');
var WKT = require('terraformer-wkt-parser');
var writeOptions = {
headers : true,
quoteHeaders : true,
quoteColumns : true,
rowDelimiter :'\n',
delimiter : ';'
};
var csvWriteStream = csv
.format(writeOptions);
var writableStream = fs.createWriteStream("C:/temp/grondwaterstroming-out.csv")
.on("finish", function(){
console.log("All done");
});
csvWriteStream.pipe(writableStream);
var readOptions = {
objectMode : true,
headers : true,
delimiter : ';',
quote : '"',
escape : '"'
};
var csvReadStream = fs.createReadStream("C:/temp/grondwaterstroming.csv");
var csvStream = csv
.parse(readOptions)
.on("data", function(data){
data.geometry = WKT.convert(JSON.parse(data.geometry));
csvWriteStream.write(data);
})
.on("end", function(){
csvWriteStream.end();
});
csvReadStream.pipe(csvStream);
node convert-geojson-to-wkt-csv.js
var csv = require('fast-csv');
var fs = require('fs');
var Terraformer = require('terraformer');
var WKT = require('terraformer-wkt-parser');
var writeOptions = {
headers : true,
quoteHeaders : true,
quoteColumns : true,
rowDelimiter :'\n',
delimiter : ';'
};
var csvWriteStream = csv
.format(writeOptions);
var writableStream = fs.createWriteStream("C:/temp/grondwaterstroming-out.csv")
.on("finish", function(){
console.log("All done");
});
csvWriteStream.pipe(writableStream);
var readOptions = {
objectMode : true,
headers : true,
delimiter : ';',
quote : '"',
escape : '"'
};
var csvReadStream = fs.createReadStream("C:/temp/grondwaterstroming.csv");
var csvStream = csv
.parse(readOptions)
.on("data", function(data){
var geometry = new Terraformer.Primitive(JSON.parse(data.geometry));
if (geometry.hasHoles()) {
console.log("found holes in " + data.id + ". let's remove the holes");
} else {
data.geometry = WKT.convert(JSON.parse(data.geometry));
csvWriteStream.write(data);
}
})
.on("end", function(){
csvWriteStream.end();
});
csvReadStream.pipe(csvStream);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
14 | |
13 | |
13 | |
12 | |
8 | |
8 | |
7 | |
5 | |
5 |