GeoJSON to DXF and DWG: Converting to CAD Without Losing Scale
"GeoJSON to DXF", "json to dwg" — the query usually comes from someone whose developer or GIS colleague handed over a JSON export, while the drawing has to happen in CAD. The format travels easily, but exactly one step decides whether you get a usable drawing or an invisible dot at the origin. Let us walk through that step, and through the small details that trip people up.
The defining property of GeoJSON
Per RFC 7946, GeoJSON always stores coordinates in WGS-84 degrees, and no other coordinate system is supposed to appear in it. They are written in longitude, latitude order — that is, the value that will become the CAD X axis comes first.
Hence the main point: numbers like [37.6173, 55.7558] are neither metres nor millimetres. A city block in such coordinates spans roughly 0.004 units, so importing the file into AutoCAD as it is gives you either a dot near the origin or invisible geometry sitting 37 units away from zero. Eyeballing a scale factor will not fix it: what you need is an honest reprojection into a metric coordinate system — a UTM zone or a local metric grid.
The very same step solves the task when your source is in another format: the Google Earth case is covered in KML and KMZ to DWG, the shapefile case in SHP to DWG.
Route 1. A single ogr2ogr command
With GDAL installed the whole conversion fits on one line:
ogr2ogr -f DXF out.dxf in.geojson -t_srs EPSG:32637
EPSG:32637 is UTM zone 37N; substitute the zone your territory falls into, or the code of the local grid. Declaring the source system is optional since GeoJSON is EPSG:4326 anyway, but an explicit -s_srs EPSG:4326 does no harm with non-standard files.
Useful additions:
- filter to what you need:
-where "highway IS NOT NULL"; - merge several files into one DXF: run again with
-append; - inspect before converting:
ogrinfo -so -al in.geojsonreports geometry types, feature counts and extent.
Route 2. Through QGIS
The option without a command line:
- Layer → Add Layer → Add Vector Layer, pick the
.geojson. - Check that the features land where they belong on the map.
- Right-click the layer → Export → Save Features As.
- Format — AutoCAD DXF; in the CRS field be sure to pick a metric system rather than "layer CRS".
- Save, open the result in AutoCAD and, if needed, re-save as DWG via File → Save As → AutoCAD Drawing.
Typical mistakes
Swapped coordinate order. If the object lands in another hemisphere or "in the ocean", the file almost certainly stores [latitude, longitude] instead of [longitude, latitude]. This is a common slip in hand-assembled JSON. Fix it in the source, not in the import settings.
Coordinates as text. Some exports emit quoted values: ["37.6173", "55.7558"]. Strictly speaking that is no longer GeoJSON, and a parser will either reject the file or read zeros. Numbers must be numbers, unquoted.
Polygons with holes. In GeoJSON the first ring of a Polygon is the outer boundary and the rest are holes (a courtyard, a lake inside an island). In DXF the holes arrive as separate closed polylines, and hatching will not cut them out automatically: pick the island detection mode by hand when you fill.
MultiPolygon and MultiLineString. Composite features break apart into individual entities. For a drawing that is usually convenient, but the object count grows.
Attributes. Everything under properties stays behind: DXF stores entities and layers, not a table — prepare labels before exporting, the procedure is in KML and KMZ to DWG.
Oversized files. GeoJSON is text and it is heavy: a district-wide export easily reaches hundreds of megabytes, and AutoCAD will be slow to open the resulting DXF. Filter before converting, or shrink the area.
The format is dissected in GeoJSON: a deep dive and The complete guide to GeoJSON, while the target format is covered in DWG: a deep dive. Which format to take for your particular CAD is worked through in Which map format to choose for CAD import.
Easier — get a ready file straight away
If the GeoJSON only ever existed as an intermediate step ("I grabbed an export, now it has to go into CAD"), the intermediate step can go. Select the territory and download it straight as DWG or DXF: OpenStreetMap data arrives split into drawing layers, in metres, in the coordinate system you choose, with no manual reprojection. And if GeoJSON itself is what you need for the web or GIS, it is available in the same place.
In short
- GeoJSON is always in WGS-84 degrees, coordinates ordered longitude then latitude.
- A direct CAD import without reprojection yields a drawing a fraction of a unit across.
- One command does the job:
ogr2ogr -f DXF out.dxf in.geojson -t_srs EPSG:32637. - Without a command line — QGIS, Export → Save Features As, DXF plus a metric CRS.
- An object in the wrong hemisphere means latitude and longitude are swapped in the source.
propertiesattributes do not travel into DXF; prepare labels before exporting.