Skip to content

Instantly share code, notes, and snippets.

@procrastinatio
Last active August 29, 2015 14:15
Show Gist options
  • Save procrastinatio/d9dc3431a2cc9dd92b96 to your computer and use it in GitHub Desktop.
Save procrastinatio/d9dc3431a2cc9dd92b96 to your computer and use it in GitHub Desktop.
PyProj and NTv2 grid
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import pyproj
DEBUG= False
_here = os.path.dirname(os.path.abspath(__file__))
proj_datadir = os.path.join(_here, 'proj_data')
os.environ["PROJ_LIB"] = os.path.join(_here, 'proj_data')
if DEBUG:
os.environ["PROJ_DEBUG"] = '5'
'''
Number CH030000129812985200
Official name (when existing) verifiziert
Coordinates LV03 (Y / X) 806260.46 / 128261.51
Coordinates MN95 (E / N) 2806262.12 / 1128261.5
Altitude (H) 1122.53
http://s.geo.admin.ch/62e1c1d598
'''
LV03_y, LV03_x = 806260.46 ,128261.51
CH_1903_LV03 = pyproj.Proj(init="CH:1903_LV03")
EPSG_2056 = pyproj.Proj(init="EPSG:2056")
EPSG_21781 = pyproj.Proj(init="EPSG:21781")
print "LV03 = (%0.2f, %0.2f)" % ( LV03_y, LV03_x)
print "LV95 PyProj = (%0.2f, %0.2f)" % (pyproj.transform(EPSG_21781, EPSG_2056, LV03_y, LV03_x))
print "LV95 NTv2 grid = (%0.2f, %0.2f)" % (pyproj.transform(CH_1903_LV03, EPSG_2056, LV03_y, LV03_x))
print "LV95 REFRAME = (%0.2f, %0.2f)" % (2806262.12, 1128261.50)
'''
>>> LV03 = (806260.46, 128261.51)
>>> LV95 PyProj = (2806260.50, 1128261.46)
>>> LV95 NTv2 grid = (2806262.12, 1128261.50)
>>> LV95 REFRAME = (2806262.12, 1128261.50)
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment