Fork of Lightning_Report adding: - n8n_report_branch.json: workflow branch for storm-triggered report delivery - report_service/: FastAPI microservice wrapping create_docx_report() so n8n can produce byte-identical reports without fighting the Python Code sandbox Made-with: Cursor
4.5 KiB
UTM ED50 to WGS84 Coordinate Converter
This script converts UTM (Universal Transverse Mercator) coordinates from ED50 (European Datum 1950) reference system to WGS84 format. It supports 6-degree UTM zones and handles both northern and southern hemispheres.
Features
- Convert single coordinates interactively
- Batch convert coordinates from CSV files
- Support for all UTM zones (1-60)
- Automatic handling of northern/southern hemispheres
- Error handling and validation
- Detailed conversion statistics
Installation
- Install the required dependencies:
pip install -r utm_converter_requirements.txt
Or install manually:
pip install pyproj pandas
Usage
Interactive Mode
Run the script in interactive mode to convert single coordinates:
python utm_ed50_to_wgs84_converter.py --interactive
Example session:
UTM ED50 to WGS84 Coordinate Converter
========================================
Enter coordinates (type 'quit' to exit)
Enter easting (meters): 500000
Enter northing (meters): 4500000
Enter UTM zone (1-60): 35
Enter hemisphere (N/S) [default: N]: N
WGS84 Coordinates:
Latitude: 40.12345678°
Longitude: 32.87654321°
----------------------------------------
Batch Conversion from CSV
Convert multiple coordinates from a CSV file:
python utm_ed50_to_wgs84_converter.py input.csv output.csv
Input CSV Format
The input CSV should contain the following columns:
| Column | Description | Required | Default |
|---|---|---|---|
easting |
UTM easting coordinate in meters | Yes | - |
northing |
UTM northing coordinate in meters | Yes | - |
zone |
UTM zone number (1-60) | Yes | - |
northern |
Hemisphere flag (True/False) | No | True |
Example input CSV:
easting,northing,zone,northern,description
500000,4500000,35,True,Sample point 1
600000,4600000,36,True,Sample point 2
400000,4400000,34,True,Sample point 3
Output CSV Format
The output CSV will contain all original columns plus:
wgs84_lat: WGS84 latitude in decimal degreeswgs84_lon: WGS84 longitude in decimal degrees
Custom Column Names
If your CSV uses different column names, specify them with command line arguments:
python utm_ed50_to_wgs84_converter.py input.csv output.csv \
--easting-col X \
--northing-col Y \
--zone-col ZONE \
--northern-col HEMISPHERE
Technical Details
Coordinate Systems
- ED50 (European Datum 1950): Historical European geodetic datum
- WGS84: World Geodetic System 1984, current global standard
- UTM: Universal Transverse Mercator projection system
Conversion Process
- ED50 UTM → WGS84 UTM: Transform between datums using pyproj
- WGS84 UTM → WGS84 Lat/Lon: Convert from projected to geographic coordinates
UTM Zones
The script supports all 60 UTM zones:
- Zones 1-60 cover the globe in 6-degree longitude bands
- Zone 1: 180°W to 174°W
- Zone 60: 174°E to 180°E
Accuracy
The conversion accuracy depends on:
- Quality of the original ED50 coordinates
- Geographic location (accuracy varies by region)
- Typically within 1-10 meters for most European locations
Examples
Example 1: Interactive Conversion
python utm_ed50_to_wgs84_converter.py --interactive
Example 2: Batch Conversion
python utm_ed50_to_wgs84_converter.py sample_utm_ed50_data.csv converted_coordinates.csv
Example 3: Custom Column Names
python utm_ed50_to_wgs84_converter.py data.csv output.csv \
--easting-col X_COORD \
--northing-col Y_COORD \
--zone-col UTM_ZONE
Error Handling
The script handles various error conditions:
- Invalid UTM zones: Must be between 1-60
- Missing columns: Reports which required columns are missing
- Invalid coordinates: Skips invalid rows and reports warnings
- File not found: Clear error messages for missing input files
Dependencies
- pyproj: Coordinate transformation library
- pandas: Data manipulation and CSV handling
- argparse: Command line argument parsing
License
This script is provided as-is for educational and practical use.
Troubleshooting
Common Issues
- "Invalid UTM zone" error: Ensure zone numbers are between 1-60
- "Missing required columns" error: Check your CSV column names
- Conversion failures: Verify coordinate values are numeric
- Import errors: Install required dependencies with pip
Getting Help
Run the script with --help for command line options:
python utm_ed50_to_wgs84_converter.py --help