I want to convert all the geojsons in a file to shapefiles in a single batch using ogr2ogr library in NodeJS. I know it can be done directly from the terminal using the gdal cli, but I want do know how to do it in Node. Thanks alot!
**I have this code to convert a single file:
// Using CommonJS modules
const ogr2ogr = require('ogr2ogr').default;
const fs = require('fs') ;
// Promise API
(async() => {
// Convert path to GeoJSON.
let {data} = await ogr2ogr('/Users/MihaiB/Desktop/test_josm/test22.geojson' );
console.log(data);
let {stream} = await ogr2ogr( data, {format: 'ESRI Shapefile'}, {destination:'/Users/MihaiB/Desktop/shapefile2.shx'});
console.log(stream)
})()