I have a dxf format file named test.dxf which has some Chinese characters inside. I tried to transform it to GeoJSON file using ogr2ogr -f GeoJSON test.geojson test.dxf and returned GeoJSON showing unrecognizable characters like this:


I also tried with ogr2ogr -f GeoJSON test.geojson test.dxf ENCODING='UTF-8' but it doesn't work out.

How can I get the result correctly?

Related reference:

Converting shapefile from Shift_JIS to UTF-8 when the usual methods fail

  • Do you mean that those characters are not using a correct Chinese character set?
    – user30184
    Commented Apr 8, 2019 at 6:10
  • No, the output of transformed Chinese characters are unrecognizable messy characters. I think maybe need to set encoding configure to ogr2ogr.
    – ah bon
    Commented Apr 8, 2019 at 8:00
  • Have you read gdal.org/drv_dxf.html and what it says about character encoding?
    – user30184
    Commented Apr 8, 2019 at 8:03
  • Yes, I just read it, please give me some advices. I have read a question's answer which says I may re-save test.dxf file with encoding utf-8 using qgis, but I hope to use command like ogr2ogr -f GeoJSON test.geojson test.dxf ENCODING='UTF-8' to transform, i'm not sure if it's possible.
    – ah bon
    Commented Apr 8, 2019 at 11:44
  • gdal.org/ogr2ogr.html
    – ah bon
    Commented Apr 8, 2019 at 12:15

1 Answer 1


you need add DXF file encoding config,this command: "--config DXF_ENCODING". eg:

ogr2ogr --config DXF_ENCODING "UTF-8" -f GeoJSON C:\\Users\\Administrator\\Desktop\\Test.geojson C:\\Users\\Administrator\\Desktop\\Test.dxf

reference resources

  • 1
    Hi Xi and welcome on GIS.Srackexchange, could you add some details to your answers. links can die after some time so it's prefered to add some text to your code Commented Jul 6, 2022 at 11:21
  • This is the correct answer in the code Commented Jul 7, 2022 at 3:46
  • I know but this code snippet is only providing immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you’ve made Commented Jul 7, 2022 at 5:51
  • ok,I have corrected it Commented Jul 8, 2022 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.