aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgk2kml.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/gk2kml.py b/gk2kml.py
index aad7408..24d842c 100755
--- a/gk2kml.py
+++ b/gk2kml.py
@@ -12,15 +12,17 @@ import argparse
from textwrap import dedent
from sys import exit
-from pyproj import CRS # Coordinate Reference System
+# Coordinate Reference System
+# from pyproj import CRS
from pyproj import Transformer
# https://spatialreference.org/ref/epsg/wgs-84/
# https://en.wikipedia.org/wiki/World_Geodetic_System
# https://epsg.io/?q=Gauss-Kruger%20kind%3APROJCRS
+
def run_argparser():
- argparser = argparse.ArgumentParser(\
+ argparser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description=dedent('''
Convert Gauss-Kru(e)ger Coordinates to WGS84
@@ -57,6 +59,7 @@ def run_argparser():
args = argparser.parse_args()
return args
+
def main():
args = run_argparser()
@@ -73,36 +76,31 @@ def main():
northing += '0'
# set zone
- if args.zone == '2':
- src_crs = 'EPSG:5682'
- elif args.zone == '3':
- src_crs = 'EPSG:5683'
- elif args.zone == '4':
- src_crs = 'EPSG:5684'
- elif args.zone == '5':
- src_crs = 'EPSG:5685'
+ if int(args.zone) >= 2 and int(args.zone) <= 5:
+ # EPS:5682 .. EPS:5685
+ src_crs = 'EPSG:568' + args.zone
else:
print('Error: Wrong zone!')
exit()
transformer = Transformer.from_crs(src_crs, 'EPSG:4326')
result = transformer.transform(easting, northing)
-
- if(str(result[0]) != 'inf'):
+
+ if (str(result[0]) != 'inf'):
print(str(result[0]) + ', ' + str(result[1]))
if args.write:
print('Writing to kml file: ' + args.write + '.kml')
template = open('template/template.kml', 'r', encoding='utf-8')
- outf = open(args.write + '.kml', 'w', encoding='utf-8',\
- errors='ignore')
+ outf = open(args.write + '.kml', 'w', encoding='utf-8',
+ errors='ignore')
line = template.readline()
while line:
line = line.replace('$NAME', args.write)
line = line.replace('$LON', str(result[1]))
line = line.replace('$LAT', str(result[0]))
- #print(line, end='')
+ # print(line, end='')
outf.write(line)
line = template.readline()
@@ -111,5 +109,6 @@ def main():
else:
print('Error: no valid result! Check input coords!')
+
if __name__ == '__main__':
main()
in each repos: see "about"-tab (if existing) for more details / README.
mailto contact at omeckman dot net
all timestamps in UTC (German winter time: UTC+01:00, summer time: UTC+02:00)
dark theme is a modded version of: https://gist.github.com/Yoplitein/f4b671a2ec70c9e743fa