3

I am using QGIS 2.4.

I need to import a map I have been given into QGIS to add some ecological survey data.

I was sent a DWG file, which consists of a base map and some overlay data, like land ownership boundaries etc. I opened this using TurboCad, and saved it as a DXF file. I can open the DXF file in TurboCad with no problem, and all looks like it did when I was using the supplied DWG.

To import the DXF file into QGIS, I tried Layer>Add Vector Layer...Source type: file... Encoding: System. When I do this (having selected all three vector layers I'm offered, and the correct CRS) the file opens, but all of the lines are now the same colour and all the overlay information has disappeared.

What is going on, and how might I address it?

5
  • 1
    I think it's because the style of the layer is different in QGIS. Double-click the layer to access its properties and select the Style tab. From there, you can change how lines should look and even alter the style of individual lines by their attributes via the Rule-based stying option.
    – Joseph
    Jan 12, 2015 at 13:07
  • Hi @Joseph, thanks for this. What you suggest sounds on the right lines - but when I open the Attribute Table in QGIS, there are 3985 features - it might be a long job to work out which is which. I wonder if it's possible to export the style from TurboCad and import it into QGIS. Alas I'm even less familiar with TurboCad than I am with QGIS!! Cheers
    – Denis
    Jan 12, 2015 at 13:23
  • Hi Denis, QGIS can import .qml (QGIS Layer Style File) and .sld (SLD) files. I'm not sure if TurboCad can export .sld files, in which case it's probably best to follow the answer posted by @Sethinacan.
    – Joseph
    Jan 12, 2015 at 13:31
  • Don't seem to be able to export SLD files - but I really know very little about TurboCad. I only ever use it for viewing documents and converting to other file formats.
    – Denis
    Jan 12, 2015 at 13:45
  • Read this gdal.org/drv_dxf.html and this gdal.org/ogr_feature_style.html. I have no own experience on DXF but it should work if you add a column named OGR_STYLE in QGIS and write the OGR style strings into this column. Example from the OGR style document: 5 pixels wide red line is defined as "PEN(c:#FF0000,w:5px)"
    – user30184
    Jan 12, 2015 at 14:07

2 Answers 2

3

For anyone reading this now consider using the plugin Another DXF Import/Converter (available for Q 2.18 and 3.x) - it will pull out the colour attributes of all text, line and polygon objects from the layer each element is on.

There are some limitations - fill styles and line styles (dashed, etc.) don't carry over. And if you have a block on Layer Blue but the individual elements (accessible in Block Editor in AutoCAD) are on Layer Black, they will be imported with the styling for Layer Black.

This allows you to bring in one complete DXF and switch layers on and off via the style (again, not exactly the same structure as in CAD programs, but pretty good nonetheless).

See below for a comparison (AutoCAD on the left, QGIS 3.6 on the right, click to enlarge)

enter image description here enter image description here

2

When I add DXF data to QGIS I just drag the DXF into the Table of contents on QGIS. You then get a layer called enitites which will include the information it can handle. You may get a box asking which types of entities you wish to import. The layer should have a field called LAYER which you can use with categorised styling. I often clean up the cad file and only bring in what I need. If you have a base map and ownerhsip info I would bring them in as two seperate DXFs. Not everything you can do in DXF is suppoorted in GIS.

0

Your Answer

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

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