Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda