empty output files when using gdal.vectorTranslate

19 Views Asked by At

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.

1

There are 1 best solutions below

1
Criminal_Affair_At_SO On BEST ANSWER

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.