Any ideas as to how can I convert dwg to shp?

I tried Kosmo and gvSIG. gvSIG kind of worked but it seems like I lost information.. in addition everything was converted into lines, no polygons. I can manually recreate the polygons, but there must be a better program to do this conversion.


  • 1
    Relima, this is complicated issue. Even with proprietary software. ESRIs ArcGIS has a big problem converting CAD drawing, most likely because of the paradigm change in how objects are handled in each environment. It is a PITA to go from CAD to GIS. It's a process that requires patiente, a lot of geoprocessing operations and luck. So good luck :P Dec 2, 2010 at 19:54
  • Thank you, Quantum GIS helped me a bit more, but you are probably right. I will have to work on it to get what I want.
    – relima
    Dec 3, 2010 at 0:04
  • is this an ongoing need or do you just need a file converted? I use autocad map and have a great deal of flexiblity in creating a shape file.
    – Brad Nesom
    Dec 3, 2010 at 4:51

5 Answers 5


Can you get your dwg as dxf? then can use the QGIS plugin DXF2Shp

alt text

If you download FME Beta (for trial) that WILL work very well.



I've had this same quest for a while now, I've managed to do it relatively easy with Kosmo in X simple steps:

  1. Convert dwg to dwg 2000 with Teigha File Converter fro the Open Design Alliance;
  2. Open this dwg in Kosmo;
  3. Save it as an ESRI Shape file, as you mention it will create 2 or 3 shapes point, polygons and lines;
  4. Select elements by the field Layer, where field layer=X and save it as x.shp
  5. Repeat step 4 until desired layer are now in shp format.

I also started a semi automated process using Python, the input would be a shp like the one described in step 3 above, from there this program would create a catalog of layers and save as a shp file all the elements from each distinct layer; the program os not working properly I don't know why but it only makes copies of the original shape file, if you run the ogr command it works OK but not when this programa runs it.

This is th python program

import shlex, subprocess, sys, fileinput from dbf import * from string import strip def process():

Read dbf

a = open ("capas1.txt","w+") print 'Ingresa el nombre del shape que deseas leer' b = raw_input() print '\n' dbf = Dbf(b+".dbf",new=False)

for rec in dbf: for fldName in dbf.fieldNames: if fldName == 'LAYER': l=() l=rec[fldName] a.write(l) a.write("\n") #dbf.close() a.close()

Get a txt with the the attribute of the dbf layers

a = open ("capas1.txt","r") catalogo = open ("unico1.txt","w") unique = set(a.read().split("\n")) catalogo.write("".join([line + "\n" for line in unique])) catalogo.close() a.close()

Execute ogr2ogr

for line in open("unico1.txt", "r"): p = subprocess.Popen(['C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr', line.replace("\n", "") +'.shp', '-where', "\"LAYER='"+ line.replace("\n", "") +"'\"" , b+'.shp']) process()

  • I think QGIS plugin uses this method as based on python - it seems much easier to use the QGIS unless you want to customise the process - which you have done very well so a +1
    – Mapperz
    Dec 3, 2010 at 15:09
  • how exactly did you open the dwg 2000 in Kosmo, I don;t seem to be ablt to do that?
    – Ligia
    Jul 12, 2012 at 9:46
  • If Kosmo can't open the dwg 2000 file try to eliminate unnecessary layers or weird things such as blocks from AutoCAD directly or use Teigha File Converter Nov 21, 2012 at 19:10

Consider ogr2ogr ( https://gdal.org/programs/ogr2ogr.html ) for future data conversion needs. It is part of the ogr ( https://gdal.org/programs/index.html#vector-program ) project. This is a command line utility to will convert to/from just about anything ( https://gdal.org/drivers/vector/index.html ).

From the website:

This program can be used to convert simple features data between file formats performing various operations during the process such as spatial or attribute selections, reducing the set of attributes, setting the output coordinate system or even reprojecting the features during translation.

  • If you look at the supported formats page for OGR, you will see that OGR can read .dxf, but not .dwg.
    – DavidF
    Dec 3, 2010 at 14:23
  • Yes, but the accepted answer converted a dxf, so I thought it appropriate... Dec 3, 2010 at 20:23
  • DWG -> DXF -> SHP worked for me. Jan 31, 2011 at 19:14
  • Tried DWG -> DXF -> SHP , but lost all the information in the attribute table.
    – Ligia
    Jul 12, 2012 at 8:35

I assume you don't have access to AutoCAD to just export to .shp?

  • No, I don't. I am trying to achieve it through free software.
    – relima
    Dec 2, 2010 at 19:31

How about the Cad to Geodatabase tool? Or were you not able to obtain the desired results using the ArcGIS conversion toos?

  • I'm confronting with exactly the same situation as Relima. Nothing from ArcGIS worked. Quantum GIS converts dxf. and i have dwg.'s and I don't have Autocad, I just received these files from a client. Plus, the files don't have any coordinate system apparently, so when I give them one, my date goes to Congo, and they are from Europe:P
    – Ligia
    Jul 12, 2012 at 8:21
  • Personally I never had a problem converting or simply viewing without conversion any DXF/DWG file in ArcGIS. Drawings often don't have any coordinate system defined in which case you have to georeference or spatially adjust based on known ground features. There is a chance the drawings where altered in in a 3rd party (non-autodesk) software and no longer conform to the autodesk standards. Jul 12, 2012 at 15:04

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.