I need js code to convert shapefile files to geojson and vice versa, and I'm having trouble to find valid tools.
I found Calvin Metcalf's repository, which should allow me to convert shapefile files to geojson, but I can't run it. Actually, I'm a novice when it comes to js, so I hope I'm making trivial mistakes.
To test it, I have:
- Put files that are part of the shapefile in the main folder;
- Ran in the same folder the
npm install shpjs --save
command from the terminal (as indicated in the README of the repository); - Created the test.js file as follow:
var shp = require('shpjs');
shp("shapefile").then(function(geojson){
console.log(geojson);
}).catch( (reason) => {
console.log('Handle rejected promise ('+reason+') here.');
});
- Ran the
node test.js
command from the terminal.
This is the output: Handle rejected promise (Error: connect ECONNREFUSED 127.0.0.1:80) here.
So, something is wrong.
I tried to look for the meaning of this error message, but I didn't understand how to handle it.
Have I made some mistakes? If not, are there any other js tools that allow me to perform conversion of these files, maybe in both directions?
EDIT
Calvin Metcalf himself answers the question in issue #128 of the repo, but I'm still having some trouble because the files I'm trying to convert are actually gigantic. So, last question still stands.
Are there any other js tools (or js friendly) that can allow me to perform a conversion from shapefile to geojson and vice versa?