Lat / Lon to CH coordinates

A small tutorial on coordinate conversion. Keywords/Keylinks:  PyProj, for Windows, for OSX Word Coordinate System: WGS84, SRID4326 Swiss Coordinate System: CH1903, SRID21781

PyProj Installation

Using python we can use a module called pyproj, which does the conversion between various coordinate systems. Pyproj build on top of Proj, the de facto open standard standard library used everywhere for these kinds of conversions. Drawback: it’s not built into python (well they cannot include EVERYTHING in their already very comprehensive package).
Two options:

  1. 1. download it here: win , mac (choose python3 to use it with Blender)
  2. 2. compile it yourself: 
    1. 1. get the source code here: pyproj-1.9.3.tar.gz
    2. 2. Unpack it. Open a Terminal window. Navigate to the folder (with cd command which means “change directory”; example cd /Users/username/Downloads/pyproj-1.9.3)
    3. 3. Compile it with the command: python3.3 setup.py install

To use it with Blender, copy the folder pyproj.1.9.3/build/lib.macosx-10.6-intel-3.3/pyproj to your Blender modules in /Users/username/Library/Application Support/Blender/2.69/scripts/modules/.

Useful Terminal command on a mac: 

open /Users/username/Library/Application\ Support/Blender/

Coordinate Conversion

Lat / Lon coordinates are the “world coordinates” and in that respect “always true” while all planar representations of it are just a distorted approximation. Therefore many countries have their own projection formula to convert lat / lon into their own coordinate system, which aims to be as precise as possible for their own spot in the world – among other mostly historical reasons for having their own coordinate system. There is a website that keeps a record of all these many different coordinate systems, spatial references as it’s called: http://spatialreference.org/. There you can find a code for the coordinate system you are looking for. Unfortunately there are many names and formats for those codes: EPSG,SRID,NAD and some other. Nonetheless if you google for one of those you’ll find something useful: The “world” has EPSG/SRID code “4326”, and the swiss coordinate system, also known as CH1903, has “21781”.

In python:

from pyproj import Proj, transform
pWorld = Proj(init=’epsg:4326′)
pCH = Proj(init=’epsg:21781′)
transform(pWorld,pCH, 47.4,8.5,0)
–> (5652905.983078045, -2897669.8111199616, 216.05401259940118)