javascriptnode.jsgdaldxfogr2ogr

empty output files when using gdal.vectorTranslate


Using gdal-async in nodejs, im trying to convert verctor files from geojson to dxf.

const dsGeoJSON2 = gdal.open('./upload2/objects.geojson'); 
const out2 = gdal.vectorTranslate('./upload2/objects.dxf', dsGeoJSON2, ['-f', 'DXF']);

the output file is emty, even with .kml but when i change to gpx for example it work.


Solution

  • Either explicitly close the output file:

    const dsGeoJSON2 = gdal.open('./upload2/objects.geojson'); 
    const out2 = gdal.vectorTranslate(
      './upload2/objects.dxf',
      dsGeoJSON2,
      ['-f', 'DXF']
    ).close();
    

    either simply quit the program.

    The flushing/closing of the file runs when the GC collects the variable holding the dataset.