0

How can I parse a 3D dxf to a kml file?

I'm looking for an answer that could point me to suitable references.

The DXF is pasted below:

  0
SECTION
  2
HEADER
  9
$ACADVER
  1
AC1006
  9
$UCSORG
  10
0.0
  20
0.0
  30
0.0
  9
$UCSXDIR
  10
1.0
  20
0.0
  30
0.0
  9
$TILEMODE
  70
1
  9
$UCSYDIR
  10
0.0
  20
1.0
  30
0.0
  9
$EXTMIN
  10
0.0
  20
0.0
  30
0.0
  9
$EXTMAX
  10
100000.0
  20
100000.0
  30
10000.0
    0
ENDSEC
  0
SECTION
  2
ENTITIES
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.804507
 30
-0.004152
 11
-105.005250
 21
57.810407
 31
-0.004152
 12
-105.003133
 22
57.807457
 32
-0.004152
 13
-105.003133
 23
57.807457
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.804507
 30
-0.004152
 11
-105.011033
 21
57.812567
 31
-0.004152
 12
-105.005250
 22
57.810407
 32
-0.004152
 13
-105.005250
 23
57.810407
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.802348
 30
-0.004152
 11
-105.011033
 21
57.812567
 31
-0.004152
 12
-105.005250
 22
57.804507
 32
-0.004152
 13
-105.005250
 23
57.804507
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.802348
 30
-0.004152
 11
-105.018933
 21
57.813357
 31
-0.004152
 12
-105.011033
 22
57.812567
 32
-0.004152
 13
-105.011033
 23
57.812567
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.018933
 20
57.801557
 30
-0.004152
 11
-105.018933
 21
57.813357
 31
-0.004152
 12
-105.011033
 22
57.802348
 32
-0.004152
 13
-105.011033
 23
57.802348
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.018933
 20
57.801557
 30
-0.004152
 11
-105.026833
 21
57.812567
 31
-0.004152
 12
-105.018933
 22
57.813357
 32
-0.004152
 13
-105.018933
 23
57.813357
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.026833
 20
57.802348
 30
-0.004152
 11
-105.026833
 21
57.812567
 31
-0.004152
 12
-105.018933
 22
57.801557
 32
-0.004152
 13
-105.018933
 23
57.801557
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.026833
 20
57.802348
 30
-0.004152
 11
-105.032616
 21
57.810407
 31
-0.004152
 12
-105.026833
 22
57.812567
 32
-0.004152
 13
-105.026833
 23
57.812567
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.032616
 20
57.804507
 30
-0.004152
 11
-105.032616
 21
57.810407
 31
-0.004152
 12
-105.026833
 22
57.802348
 32
-0.004152
 13
-105.026833
 23
57.802348
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.032616
 20
57.804507
 30
-0.004152
 11
-105.034733
 21
57.807457
 31
-0.004152
 12
-105.032616
 22
57.810407
 32
-0.004152
 13
-105.032616
 23
57.810407
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.802348
 30
-0.114152
 11
-105.026833
 21
57.802348
 31
-0.114152
 12
-105.018933
 22
57.801557
 32
-0.114152
 13
-105.018933
 23
57.801557
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.802348
 30
-0.114152
 11
-105.032616
 21
57.804507
 31
-0.114152
 12
-105.026833
 22
57.802348
 32
-0.114152
 13
-105.026833
 23
57.802348
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.804507
 30
-0.114152
 11
-105.032616
 21
57.804507
 31
-0.114152
 12
-105.011033
 22
57.802348
 32
-0.114152
 13
-105.011033
 23
57.802348
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.804507
 30
-0.114152
 11
-105.034733
 21
57.807457
 31
-0.114152
 12
-105.032616
 22
57.804507
 32
-0.114152
 13
-105.032616
 23
57.804507
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.003133
 20
57.807457
 30
-0.114152
 11
-105.034733
 21
57.807457
 31
-0.114152
 12
-105.005250
 22
57.804507
 32
-0.114152
 13
-105.005250
 23
57.804507
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.003133
 20
57.807457
 30
-0.114152
 11
-105.032616
 21
57.810407
 31
-0.114152
 12
-105.034733
 22
57.807457
 32
-0.114152
 13
-105.034733
 23
57.807457
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.810407
 30
-0.114152
 11
-105.032616
 21
57.810407
 31
-0.114152
 12
-105.003133
 22
57.807457
 32
-0.114152
 13
-105.003133
 23
57.807457
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.810407
 30
-0.114152
 11
-105.026833
 21
57.812567
 31
-0.114152
 12
-105.032616
 22
57.810407
 32
-0.114152
 13
-105.032616
 23
57.810407
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.812567
 30
-0.114152
 11
-105.026833
 21
57.812567
 31
-0.114152
 12
-105.005250
 22
57.810407
 32
-0.114152
 13
-105.005250
 23
57.810407
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.812567
 30
-0.114152
 11
-105.018933
 21
57.813357
 31
-0.114152
 12
-105.026833
 22
57.812567
 32
-0.114152
 13
-105.026833
 23
57.812567
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.812567
 30
-0.004152
 11
-105.018933
 21
57.813357
 31
-0.114152
 12
-105.011033
 22
57.812567
 32
-0.114152
 13
-105.011033
 23
57.812567
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.812567
 30
-0.004152
 11
-105.018933
 21
57.813357
 31
-0.004152
 12
-105.018933
 22
57.813357
 32
-0.114152
 13
-105.018933
 23
57.813357
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.810407
 30
-0.004152
 11
-105.011033
 21
57.812567
 31
-0.114152
 12
-105.005250
 22
57.810407
 32
-0.114152
 13
-105.005250
 23
57.810407
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.810407
 30
-0.004152
 11
-105.011033
 21
57.812567
 31
-0.004152
 12
-105.011033
 22
57.812567
 32
-0.114152
 13
-105.011033
 23
57.812567
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.810407
 30
-0.004152
 11
-105.003133
 21
57.807457
 31
-0.114152
 12
-105.003133
 22
57.807457
 32
-0.004152
 13
-105.003133
 23
57.807457
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.810407
 30
-0.004152
 11
-105.005250
 21
57.810407
 31
-0.114152
 12
-105.003133
 22
57.807457
 32
-0.114152
 13
-105.003133
 23
57.807457
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.003133
 20
57.807457
 30
-0.004152
 11
-105.005250
 21
57.804507
 31
-0.114152
 12
-105.005250
 22
57.804507
 32
-0.004152
 13
-105.005250
 23
57.804507
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.003133
 20
57.807457
 30
-0.004152
 11
-105.003133
 21
57.807457
 31
-0.114152
 12
-105.005250
 22
57.804507
 32
-0.114152
 13
-105.005250
 23
57.804507
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.804507
 30
-0.004152
 11
-105.011033
 21
57.802348
 31
-0.114152
 12
-105.011033
 22
57.802348
 32
-0.004152
 13
-105.011033
 23
57.802348
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.005250
 20
57.804507
 30
-0.004152
 11
-105.005250
 21
57.804507
 31
-0.114152
 12
-105.011033
 22
57.802348
 32
-0.114152
 13
-105.011033
 23
57.802348
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.802348
 30
-0.004152
 11
-105.018933
 21
57.801557
 31
-0.114152
 12
-105.018933
 22
57.801557
 32
-0.004152
 13
-105.018933
 23
57.801557
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.011033
 20
57.802348
 30
-0.004152
 11
-105.011033
 21
57.802348
 31
-0.114152
 12
-105.018933
 22
57.801557
 32
-0.114152
 13
-105.018933
 23
57.801557
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.018933
 20
57.801557
 30
-0.004152
 11
-105.026833
 21
57.802348
 31
-0.114152
 12
-105.026833
 22
57.802348
 32
-0.004152
 13
-105.026833
 23
57.802348
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.018933
 20
57.801557
 30
-0.004152
 11
-105.018933
 21
57.801557
 31
-0.114152
 12
-105.026833
 22
57.802348
 32
-0.114152
 13
-105.026833
 23
57.802348
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.026833
 20
57.802348
 30
-0.004152
 11
-105.032616
 21
57.804507
 31
-0.114152
 12
-105.032616
 22
57.804507
 32
-0.004152
 13
-105.032616
 23
57.804507
 33
-0.004152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.026833
 20
57.802348
 30
-0.004152
 11
-105.026833
 21
57.802348
 31
-0.114152
 12
-105.032616
 22
57.804507
 32
-0.114152
 13
-105.032616
 23
57.804507
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.034733
 20
57.807457
 30
-0.004152
 11
-105.032616
 21
57.804507
 31
-0.114152
 12
-105.034733
 22
57.807457
 32
-0.114152
 13
-105.034733
 23
57.807457
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.034733
 20
57.807457
 30
-0.004152
 11
-105.032616
 21
57.804507
 31
-0.004152
 12
-105.032616
 22
57.804507
 32
-0.114152
 13
-105.032616
 23
57.804507
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.032616
 20
57.810407
 30
-0.004152
 11
-105.034733
 21
57.807457
 31
-0.114152
 12
-105.032616
 22
57.810407
 32
-0.114152
 13
-105.032616
 23
57.810407
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.032616
 20
57.810407
 30
-0.004152
 11
-105.034733
 21
57.807457
 31
-0.004152
 12
-105.034733
 22
57.807457
 32
-0.114152
 13
-105.034733
 23
57.807457
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.026833
 20
57.812567
 30
-0.004152
 11
-105.032616
 21
57.810407
 31
-0.114152
 12
-105.026833
 22
57.812567
 32
-0.114152
 13
-105.026833
 23
57.812567
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.026833
 20
57.812567
 30
-0.004152
 11
-105.032616
 21
57.810407
 31
-0.004152
 12
-105.032616
 22
57.810407
 32
-0.114152
 13
-105.032616
 23
57.810407
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.018933
 20
57.813357
 30
-0.004152
 11
-105.026833
 21
57.812567
 31
-0.114152
 12
-105.018933
 22
57.813357
 32
-0.114152
 13
-105.018933
 23
57.813357
 33
-0.114152
  0
3DFACE
  8
Body
 62
0
 420
255
 10
-105.018933
 20
57.813357
 30
-0.004152
 11
-105.026833
 21
57.812567
 31
-0.004152
 12
-105.026833
 22
57.812567
 32
-0.114152
 13
-105.026833
 23
57.812567
 33
-0.114152
  0
ENDSEC
  0
EOF
1

I would recommend FME to do the job. (http://www.safe.com/) The ability to manipulate datasets to/from many different formats and easily wrap them into batch files will more than pay for itself over time.

  • 1
    this can done online with demos.fmeserver.com/easytranslator/index.html – Mapperz Feb 16 '15 at 21:36
  • Thx. tried this...getting "fatal errors" when I feed it the DXF. – val Feb 17 '15 at 0:28
  • @val can you post the 3d dxf file online? – Mapperz Feb 17 '15 at 2:47
  • @Mapperz: File pasted above. – val Feb 17 '15 at 23:04
  • @Mapperz: seems it has worked. I had previously failed to select a coordinate system (I let it guess). This time i selected WGS84. Just playing with the KML at this point. – val Feb 18 '15 at 2:02
1

You should be able to use the GDAL ogr2ogr tool to convert a file from DXF to a KML.

ogr2ogr -f "KML" out.kml in.dxf -s_srs "source srs" -t_srs EPSG:4326

This will require that the DXF be georeferenced, and that you know can determine the spatial reference system of the source.

  • Thx. I've georeferenced it to lat/long as I'm thinking this could be the easiest to use (at least to start). Normally I deal with UTMs. – val Feb 17 '15 at 0:23
  • 1
    I tried DXF file you added to the question with GDAL version 1.11.1, and assumed the spatial reference was WGS 84 (EPSG:4326) and was able to produce a KML that loaded in Google Earth. – Andy C Feb 18 '15 at 19:50
  • 1
    You can also convert directly from the UTM based files by specifying the correct UTM zone EPSG identifier, it looks like this data would be in UTM 13 North - so it would be EPSG:32613 for the source srs. – Andy C Feb 18 '15 at 20:02
  • Does this conversion restrict the data to 2D? I have a 3D DXF. In GE it seems to only plot the 2D projection, or a slice of my model. Also, when I retrieve information on Code 4326 here epsg-registry.org, it seems to convert to a 2D projection, i.e. (Type = GeodeticCRS (geographic 2D)". I want a 3D DXF converted to a KML (also in 3D). – val Feb 18 '15 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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