How to Open DXF Files in QGIS

How to Open DXF Files in QGIS

QGIS is a free, open source GIS program used by planners, surveyors, environmental teams and city governments. A lot of the data these teams receive comes from CAD: site plans, survey drawings, road designs and utility layouts, often as DXF files. QGIS can open them, show them on a map and turn them into proper GIS layers.

This guide shows how to open a DXF in QGIS, set the right coordinate system, convert CAD layers into GIS data, and export your map back to DXF for CAD users.

CAD and GIS think differently

Before you start, it helps to know why DXF files can be tricky in GIS.

  • CAD files have no map projection. A DXF stores X and Y numbers, but it does not say which coordinate system they belong to. GIS needs to know that to place the drawing on the earth.
  • CAD uses layers for drawing, GIS uses layers for data. A CAD layer called ROADS might hold lines, text and hatches all together. GIS prefers one geometry type per layer.
  • CAD drawings may use local coordinates. Many site plans start at 0,0 or some made up point, not real world coordinates.

Knowing this saves a lot of confusion. If your DXF lands in the ocean off Africa, it is not broken. It just has no correct coordinate system yet.

Check the DXF first

Open the file in our free online DXF viewer. It does not upload anything.

  • Look at the coordinate values in the status bar as you move the mouse. Large numbers, like 500000 and 4000000, often mean real world coordinates in a projected system such as UTM. Small numbers, like 0 to 200, often mean local coordinates.
  • Check the units in the status bar, if the file stores them.
  • Look at the layers to see what data you have.

Then ask the person who made the file which coordinate system they used. That one answer can save hours.

Method 1: Add the DXF as a vector layer

  1. Open QGIS and start a new project.
  2. Go to Layer, then Add Layer, then Add Vector Layer. Or drag the DXF from your file manager into the map.
  3. Pick the DXF file and click Add.
  4. QGIS may ask which sublayers to add, such as points, lines and polygons. Select what you need.
  5. If QGIS asks for a coordinate system, pick the one the surveyor or designer used.

The DXF appears on the map. You can style it, label it and use it like any other layer, though it stays read only while it is a DXF.

Method 2: Import the DXF with layers and blocks

QGIS also has an import tool that keeps much more of the CAD structure. It is found under Project, then Import/Export, then Import Layers from DWG/DXF.

  1. Open the import tool.
  2. Choose a target GeoPackage file. QGIS stores the imported data there.
  3. Set the coordinate system the drawing uses.
  4. Pick the DXF file and click Import.
  5. QGIS lists the CAD layers. Tick the ones you want to load.
  6. Choose whether to merge layers and whether to expand blocks.
  7. Click OK.

This method keeps CAD layer names and much of the original styling. The result is a GeoPackage, so the data becomes editable GIS data.

Set the right coordinate system

This is the most important step. If the DXF uses real world coordinates, you only need to tell QGIS which system it is.

  1. Right-click the layer and open Properties.
  2. Go to the Source tab.
  3. Set the coordinate system to the one the drawing used, such as a national grid or a UTM zone.
  4. Click OK. The drawing should now sit in the right place over a basemap.

To check, add an online basemap from the browser panel, such as OpenStreetMap. If roads in the DXF line up with roads on the map, you have the right system.

What if the DXF uses local coordinates?

Then the drawing needs to be moved, rotated and maybe scaled into place. This is called georeferencing. You will need a few points with known real world coordinates, such as survey control points. QGIS processing tools can apply an affine transformation to a vector layer using those points. If this is new to you, ask the surveyor for a version of the DXF in real world coordinates. Most can export one easily.

Convert CAD layers into clean GIS layers

Once the DXF is in the right place, you will usually want real GIS data.

  1. Filter the layer to the CAD layer you need. Right-click, choose Filter, and set the Layer field equal to a name such as ROADS.
  2. Right-click the filtered layer and choose Export, then Save Features As.
  3. Save it as a GeoPackage or shapefile with the right coordinate system.
  4. Repeat for each CAD layer you need.

Now you have separate, editable GIS layers for roads, buildings, boundaries and so on.

Turning lines into polygons

CAD buildings and parcels are often closed lines, not polygons. Use the Lines to Polygons or Polygonize tool from the Processing Toolbox. Polygonize works well when outlines are made of many separate lines that touch.

How to export DXF from QGIS

CAD users on your team or at the engineering firm will often ask for DXF. QGIS can export the whole map or selected layers.

  1. Go to Project, then Import/Export, then Export Project to DXF.
  2. Pick a file name.
  3. Choose the symbology mode. No symbology exports plain geometry. Feature symbology keeps colors and line styles where possible.
  4. Set the scale for symbol sizes, if you keep symbology.
  5. Set the coordinate system the CAD user needs.
  6. Tick the layers to export. You can choose a field to split a layer into CAD layers, such as a road type field.
  7. Click OK.

Open the result in our online DXF viewer. Check the coordinates in the status bar and make sure all layers came through. Then send it to the CAD user with a note about the coordinate system.

Real example: a planning team and a new subdivision

A city planner receives a DXF of a proposed subdivision from a developer’s engineer. She needs to check it against zoning maps in QGIS.

  1. She opens the DXF in a viewer. The coordinates are large numbers, so it is likely in the local projected system.
  2. She emails the engineer and confirms the system.
  3. In QGIS, she uses Import Layers from DWG/DXF into a GeoPackage with that coordinate system.
  4. She adds an aerial basemap. The new roads line up with the existing street grid.
  5. She exports the lot lines as their own layer and runs Polygonize to create lot polygons.
  6. She overlays the zoning layer and spots two lots that fall under the minimum size.

The check that used to need a CAD specialist now takes her a morning in free software.

Common QGIS DXF problems

The DXF appears in the wrong place

The coordinate system is wrong or missing. Set the correct one in layer properties. If the file uses local coordinates, it needs georeferencing.

Text and hatches clutter the map

Filter the layer by CAD layer name, or only load line and polygon sublayers.

Buildings show as lines, not areas

Use Lines to Polygons or Polygonize.

The DXF will not load

It may be binary, damaged or a DWG with the wrong name. See DXF file not opening and DWG to DXF.

Arcs look like straight segments

GIS often stores curves as many short segments. This is normal and usually fine for mapping.

Styling DXF layers so they read well

Raw CAD colors often look odd over an aerial photo. Use the layer styling panel to pick clear colors and line widths. A categorized style on the CAD layer name field works well. Give roads one color, buildings another and boundaries a dashed line. Turn off text you do not need, and add QGIS labels instead, which scale better on screen and in print.

Tips for working with CAD data in QGIS

  • Always confirm the coordinate system with the file’s creator. Guessing wastes time.
  • Keep the original DXF unchanged. Work on GeoPackage copies.
  • Use the GeoPackage import when you want CAD styles and block names kept.
  • Write the coordinate system in the file name of every export, such as plan_EPSG32633.dxf.
  • Check exports in a DXF viewer before sending them to CAD users.

Frequently asked questions

Is QGIS free?

Yes. QGIS is free and open source for Windows, Mac and Linux.

Can QGIS open DWG files?

The import tool can read DWG files in recent versions. If you have trouble, convert to DXF first.

Why does my DXF have no coordinate system?

DXF files do not store one. You must set it in QGIS.

Can I edit a DXF directly in QGIS?

Not as a DXF. Import it into a GeoPackage or save it as a shapefile, then edit.

What other programs open DXF files?

See our list of programs that open DXF files.

Check your DXF first

Open the file in our free DXF viewer before loading it into QGIS. Look at the coordinates, check the units and see which layers you need. It makes the GIS side much smoother.

Similar Posts