GeoTIFF Conversion from DXF/TIFF
Overview
The GeoTIFF map type in Configuration requires files in the WGS84 / EPSG coordinate system. Map exports from CAD tools are often delivered in a local projected system instead (e.g. SIRGAS 2000 UTM), and need to be converted first.
Two Python scripts are provided for this conversion:
| Script | Input | Best for |
|---|---|---|
dxf_to_wgs84_geotiff.py |
DXF file | Pixel-accurate output — renders geometry directly from the DXF |
tiff_to_wgs84.py |
TIFF + DXF | Re-uses an existing rendered TIFF; trims page margins automatically |
Downloads: dxf_to_wgs84_geotiff.py · tiff_to_wgs84.py
Requirements
pip install rasterio pyproj ezdxf numpy matplotlib
Note
matplotlib is only required by dxf_to_wgs84_geotiff.py.
English
dxf_to_wgs84_geotiff.py
Reads the spatial extent from the DXF header, renders all line geometry (lines, polylines) with their original colours onto a georeferenced canvas, and reprojects the result to WGS84.
Usage
python dxf_to_wgs84_geotiff.py <input.dxf> [--out OUTPUT] [--epsg EPSG] [--res RESOLUTION]
| Argument | Description | Default |
|---|---|---|
input.dxf |
Path to the source DXF file (required) | — |
--out |
Output GeoTIFF filename | output_wgs84.tiff |
--epsg |
EPSG code for the SIRGAS 2000 UTM zone | 31982 (Zone 22S) |
--res |
Output resolution in metres per pixel | 2.0 |
Examples
# Minimal
python dxf_to_wgs84_geotiff.py my_map.dxf
# Custom output and zone 23S
python dxf_to_wgs84_geotiff.py my_map.dxf --out mine_wgs84.tiff --epsg 31983
# Higher resolution (1 m/px)
python dxf_to_wgs84_geotiff.py my_map.dxf --res 1.0
tiff_to_wgs84.py
Takes an ungeoreferenced TIFF (typically a page-layout export from a CAD tool), automatically detects the map content area by trimming white page margins, maps the content to the bounding box read from the DXF header, and reprojects to WGS84.
Usage
python tiff_to_wgs84.py <input.tiff> <input.dxf> [--out OUTPUT] [--epsg EPSG]
| Argument | Description | Default |
|---|---|---|
input.tiff |
Path to the source TIFF file (required) | — |
input.dxf |
Path to the DXF file for the bounding box (required) | — |
--out |
Output GeoTIFF filename | output_wgs84.tiff |
--epsg |
EPSG code for the SIRGAS 2000 UTM zone | 31982 (Zone 22S) |
Examples
# Minimal
python tiff_to_wgs84.py export.tiff map.dxf
# Custom output and zone 23S
python tiff_to_wgs84.py export.tiff map.dxf --out mine_wgs84.tiff --epsg 31983
EPSG codes for SIRGAS 2000 UTM zones
| Code | Zone | Longitude range |
|---|---|---|
| 31981 | 21S | 57°W – 51°W |
| 31982 | 22S | 51°W – 45°W |
| 31983 | 23S | 45°W – 39°W |
| 31984 | 24S | 39°W – 33°W |
Notes
- On Windows, run with
python -X utf8 <script>to avoid console encoding issues. - Both scripts output a LZW-compressed RGBA GeoTIFF that can be opened in QGIS, ArcGIS, Google Earth Pro, or any other GIS software, and uploaded directly as a GeoTIFF map layer in GroundControl.