Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

Ideas?

share|improve this question
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 –  George Dec 2 '10 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 '10 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 '10 at 4:51
add comment

5 Answers 5

up vote 3 down vote accepted

Relima;

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()

share|improve this answer
    
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 '10 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 '12 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 –  jdeltoro1973 Nov 21 '12 at 19:10
add comment

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

share|improve this answer
    
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 '12 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. –  Jakub Jul 12 '12 at 15:04
add comment

Consider ogr2ogr ( http://www.gdal.org/ogr2ogr.html ) for future data conversion needs. It is part of the ogr ( http://www.gdal.org/ogr/ ) project. This is a command line utility to will convert to/from just about anything ( http://www.gdal.org/ogr/ogr_formats.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."

share|improve this answer
    
If you look at the supported formats page for OGR, you will see that OGR can read .dxf, but not .dwg. –  DavidF Dec 3 '10 at 14:23
    
Yes, but the accepted answer converted a dxf, so I thought it appropriate... –  Dave Lowther Dec 3 '10 at 20:23
    
DWG -> DXF -> SHP worked for me. –  Andrew Lewis Jan 31 '11 at 19:14
    
Tried DWG -> DXF -> SHP , but lost all the information in the attribute table. –  Ligia Jul 12 '12 at 8:35
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
    
No, I don't. I am trying to achieve it through free software. –  relima Dec 2 '10 at 19:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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