A user-friendly command-line tool for reprojecting coordinates in DXF (AutoCAD) files from one coordinate reference system (CRS) to another.
This tool parses DXF files, identifies coordinate sets in AcDbFace and 3DFACE sections, reprojects the X and Y coordinates using pyproj, and writes out new DXF files with the updated coordinates.
- Clone this repository:
git clone https://github.com/RichardScottOZ/DXF-Reprojection.git
cd DXF-Reprojection- Install dependencies:
pip install -r requirements.txtReproject a single DXF file:
python dxf_reproject.py -i input.dxf -o output.dxf -s EPSG:20254 -t EPSG:28354Reproject all DXF files in a directory:
python dxf_reproject.py -i ./input_dir -o ./output_dir -s EPSG:20254 -t EPSG:28354 -i, --input INPUT Input DXF file or directory containing DXF files
-o, --output OUTPUT Output DXF file or directory for reprojected files
-s, --source-crs CRS Source coordinate reference system (e.g., EPSG:20254)
-t, --target-crs CRS Target coordinate reference system (e.g., EPSG:28354)
--suffix SUFFIX Suffix to add to output filenames (default: extracted from target CRS)
--overwrite Overwrite existing output files without asking
-h, --help Show help message and exit
Example 1: Convert from AGD66 to GDA94
python dxf_reproject.py -i survey.dxf -o survey_gda94.dxf -s EPSG:20254 -t EPSG:28354Example 2: Batch process multiple files
python dxf_reproject.py -i ./original_files -o ./reprojected_files -s EPSG:20254 -t EPSG:28354Example 3: Use custom suffix
python dxf_reproject.py -i ./input -o ./output -s EPSG:20254 -t EPSG:28354 --suffix wgs84EPSG:4326- WGS 84 (GPS coordinates)EPSG:3857- Web Mercator (used by Google Maps, OpenStreetMap)EPSG:28354- GDA94 / MGA zone 54 (Australia)EPSG:20254- AGD66 / AMG zone 54 (Australia, legacy)EPSG:32754- WGS 84 / UTM zone 54S
You can find more EPSG codes at epsg.io
- ✅ User-friendly command-line interface
- ✅ Support for single file or batch directory processing
- ✅ Progress bars for batch operations
- ✅ CRS validation before processing
- ✅ Error handling and informative messages
- ✅ Automatic output filename generation with CRS suffix
- ✅ Safety check to prevent overwriting files accidentally
The tool uses a text-based parsing approach:
- Reads the DXF file as text
- Identifies coordinate sections marked by
AcDbFaceand3DFACEtags - Extracts X, Y coordinate pairs
- Reprojects coordinates using pyproj's Transformer
- Replaces original coordinates with reprojected values
- Writes out the updated DXF file
Note: This approach works well for files with reasonable numbers of coordinates. For DXF files with millions of coordinates, consider a vectorized/parallelized version for better performance.
The original Jupyter notebook (DXF-Parsing.ipynb) is still available for interactive use and experimentation.
- Python 3.6+
- pandas
- pyproj
- tqdm
This project is open source. Please check the repository for license details.
Contributions are welcome! Please feel free to submit issues or pull requests.