DXF to GeoPackage Converter
Import CAD vector drawings into projected spatial databases.
CAD files (DXF) lack intrinsic coordinate reference systems (CRS) by default. To translate them into spatial databases, you must assign a target projection. This guide demonstrates how to establish coordinate grids and clean spatial vector layers.
Indirect Mapping Execution Required
Because database connection attributes or local attributes parsing is required, direct web streams are disabled. Use the GDAL CLI script below for precise terminal conversions.
Specification Rules
- Import engineering and planning drafts directly into municipal databases
- Transform architectural line work into GIS-ready layout vectors
- Export CAD boundaries into multi-layer spatial environments
- Requires manual assignment of projected Coordinate Reference Systems
- Detailed AutoCAD layout annotations do not translate directly to GIS variables
- Vast spatial scales are prone to geometric stretching
GDAL Direct Equivalent Terminal Command
When to use this conversion
Convert when a CAD design (AutoCAD drawing exported as DXF, surveyor site plan, architect floor plan) needs to enter a GIS workflow. GeoPackage is the right target because it preserves layer names, accepts arbitrary attribute schemas, and stores the assigned CRS properly.
Technical Details
GeoPackage is typically 30–60% the size of the source DXF. ASCII DXF is very verbose; GeoPackage's binary geometry encoding compresses dramatically. Large block-heavy drawings can compress further once blocks are flattened.
Common Errors & Fixes
- Lines appear off the coast of Africa: DXF has no CRS, so local coordinates were interpreted as lat/lon. Fix: assign the correct source CRS with -a_srs EPSG:<code>.
- Curves jagged: arcs were approximated as low-segment polylines. Fix: increase DXF_INLINE_BLOCKS arc segments via -oo DXF_INLINE_BLOCKS=TRUE plus custom config.
- Layer information lost: CAD layer names appear as a generic "Layer" column with cryptic IDs. Fix: use the LIBKML driver to expose layer names as proper attributes, or pre-process the DXF.
- Text annotations not imported: TEXT and MTEXT entities are dropped by default. Fix: enable text import with -oo DXF_FEATURE_LIMIT_PER_BLOCK and check the points layer.
Alternative Tools
- QGIS: Layer → Add Layer → Add Vector Layer with the DXF, then assign CRS and export to GeoPackage
- ogr2ogr CLI: ogr2ogr -f GPKG output.gpkg input.dxf -a_srs EPSG:<code>
- FME for advanced CAD-to-GIS workflows with block-name attribution
- ezdxf (Python) for programmatic preprocessing before conversion
Frequently Asked Questions
Why is the coordinate alignment incorrect after conversion?
DXF coordinates are typically localized grids. To align with global mapping models, you must assign a Spatial Reference using the '-a_srs' argument.
Are CAD layers preserved in the GeoPackage?
Yes. Each DXF layer translates to a corresponding table feature in the output database.
Does GDAL parse text block entities?
Yes. CAD block labels convert to point layers with metadata descriptions containing the label string values.