Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Converting geoJson to shapfile as batch using GDAL ogr2ogr in Node JS

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)       
  
})()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After all, the solution seemed to be pretty easy (even if it took way to long to figure it out) I had to use dirTree package to get the paths for all the files in a given folder

const ogr2ogr = require('ogr2ogr').default;
const PATH = require('path');
const dirTree = require('directory-tree');

  // Promise API
( async() => {
  
  // List Files in a Directory using dirTree package
  const tree = dirTree('/Users/MihaiB/Desktop/test_josm/', {extensions:/\.geojson$/}, 
  
  async (item, PATH, stats) => {
  console.log(PATH);
        
  // Convert path to GeoJSON
  let {data} = await ogr2ogr(PATH);
  console.log(data);

  // Convert GeoJSON to Shapefile
  let {stream} = await ogr2ogr( data, {format: 'ESRI Shapefile', destination:'/Users/MihaiB/Desktop/batch2/'});
  console.log(stream)

 }); 
})
()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!