The DWG format is an Autocad proprietary binary
format. When we want to load layers in
QGis from this format, multiple problems arise.
QGis uses the GDAL library to read / write external formats ,
such as DWG.
Firstly a clarification: do not confuse the DWG format and
DXF format. Often references for DWG / DXF
format are found which is a misuse of language. Both
formats are different . The
DWG format is the native format for Autocad software.
is a proprietary format and, in theory,
subject to license. The DXF format is a data
export format for Autocad software.
public and not subject to license.
If you have at your disposal DXF
files none of the problems raised in
The first concern arises from the fact that several versions
of the DWG format exist.
The GDAL library used by QGis, is compiled
with the libopencad library that manages some of these versions, but
not all . You will get a
message such as the following
In the case where the version is
by libopencad you will
get a window similar to:
/ GIS Software
In the previous window we can see the conceptual difference
CAD and GIS software. In the drawing software , the
objects are grouped in
“layers ” in this window
. We must not confuse the layer concept with the GIS layer.
GDAL tries to move from one notion to another and
is why you have in
proposal for GIS layers built from layers of the DWG drawing file.
The first line suggest a 0-FB1-archive
layer with 7 entities of linear type . It
corresponds to a layer of that name where the designer has placed just the
linear objects . For
this layer / layer there is, a priori, no
Nevertheless, a a little further down, we
have a “BORNES” layer with 39 entities but
with a “Geometry Collection” type geometry .
This, clearly, means that the objects
on this layer are of different types : lines , points, text , etc …
GDAL cannot create a single
GIS-type layer from the layer without losing, eventually, important information.
For the time being, QGis does not support layers with different
geometries (I believe, only
multi-type geometries). If you select
TERMS and click OK, you will see
new layer in the layers panel , but of the DATASET type
You will not see any
on your cartographic
the attribute table you can
the contents of this DATASET
You can see
that the original layer contained circles and
text. Nevertheless, this layer
QGis because no geometry is
with the layer and, therefore, we cannot display it on the map.
The other problem that arises but,
usually, when importing data from
the CAD software, is how to manage symbology entities. In
the symbology is managed
the entities data. It is not stored as data, at the
most it can be stored
separated files, such as QML or SLD.
In the list of layers shown above you can
a FAS-hatch- built layer that contains hatches of buildings .
These layers are useless during
the integration in a GIS.
Until GDAL can solve all
here is a workaround.
You can install and use a free
program to turn DWG files into DXF, before loading them into QGIS.
ODA File Converter (Open Design Alliance) allows converting
the different versions of DWG to the DXF format.
Once installed , when running it, you will get
the following window:
You can select
the most recent version of the DXF format as it does not pose any
integration problem with GDAL and QGIS.
The program converts all the DWG files of a
directory , and possibly subdirectories (if
the Recursive folders box ).
Besides, the fact of having a
a readable format by QGis, the program groups all
entities in three types of entities : points, lines and polygons
, plus one Geometry Collection class .
Unlike GDAL and Libopencad
, you will see a reduced number of Geometry Collections.
Only the collections that ODA cannot interpret (eg CADAttdef)
will remain as collections.
Others, such as the layer TERMINALS we have discussed above,
will be converted as points for the texts (with TEXT
attribute ) and lines for the circles .
The result , if you load
the three layers (Point, LineString and Polygon) will be of the
A cleaning job to remove drawing artefacts will be
essential to retain only the data itself:
This can be easily done since the attribute table
the name of the original layer for each