{"id":419,"date":"2011-05-30T22:30:23","date_gmt":"2011-05-30T20:30:23","guid":{"rendered":"http:\/\/visurus.wordpress.com\/?p=419"},"modified":"2013-08-19T12:05:56","modified_gmt":"2013-08-19T12:05:56","slug":"projection-from-wgs1984-to-swiss-national-grid-ch1903-lv03","status":"publish","type":"post","link":"https:\/\/www.ralphstraumann.ch\/blog\/2011\/05\/projection-from-wgs1984-to-swiss-national-grid-ch1903-lv03\/","title":{"rendered":"Projection from WGS1984 to Swiss national grid (CH1903 LV03)"},"content":{"rendered":"<p>In <a href=\"https:\/\/visurus.wordpress.com\/2011\/05\/12\/gefahrdung-der-bevolkerung-der-schweiz-durch-kernkraftwerke-eine-analyse\/\">my last project<\/a> I used (standalone) Python for geoprocessing. Since <a class=\"zem_slink\" title=\"ArcGIS\" href=\"http:\/\/en.wikipedia.org\/wiki\/ArcGIS\" rel=\"wikipedia\">ArcGIS<\/a> or something like that was not there to help with projecting geodata from one coordinate system to another, I wrote a function which converts well-known <a href=\"http:\/\/en.wikipedia.org\/wiki\/WGS84\">WGS1984<\/a>\u00a0to\u00a0Swiss national grid coordinates (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Swiss_coordinate_system\">Swissgrid<\/a>,\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Swiss_coordinate_system\">CH1903 LV03<\/a>).<\/p>\n<p><a href=\"http:\/\/www.swisstopo.admin.ch\/internet\/swisstopo\/en\/home.html\">Swisstopo<\/a> has the\u00a0<a href=\"http:\/\/www.swisstopo.admin.ch\/internet\/swisstopo\/en\/home\/products\/software\/products\/skripts.html\">formulas<\/a>\u00a0of an approximate transformation and also funtions in C#, Javascript and PHP, but not in Python. So here is to your disposal:<\/p>\n<p>[sourcecode language=&#8221;python&#8221; gutter=&#8221;false&#8221;]<br \/>\ndef\u00a0projWGS1984ToCH1903(x, y):<br \/>\n&#8220;&#8221;&#8221;Converts coordinates from WGS1984 to CH1903_LV03 using the<br \/>\nmethod from http:\/\/www.swisstopo.admin.ch\/internet\/swisstopo\/<br \/>\nde\/home\/products\/software\/products\/skripts.html, returns a<br \/>\nlist [x,y]<br \/>\n:param x: x\u00a0coordinates\u00a0in degrees in WGS1984 :<br \/>\n:param y: y coordinates in degrees in WGS1984 &#8220;&#8221;&#8221;<\/p>\n<p># Transformation into sexagesimal seconds<br \/>\nx = x * 3600<br \/>\ny = y * 3600<\/p>\n<p># Latitude and longitude difference to Bern<br \/>\nx_fact = (x &#8211; 26782.5) \/ 10000 # LAMBDA<br \/>\ny_fact = (y &#8211; 169028.66) \/ 10000 # PHI<\/p>\n<p>x = 600072.37 + 211455.93 * x_fact &#8211; 10938.51 * x_fact * y_fact &#8211; 0.36 * x_fact * y_fact**2 &#8211; 44.54 * x_fact**3<br \/>\ny = 200147.07 + 308807.95 * y_fact + 3745.25 * x_fact**2 + 76.63 * y_fact**2 &#8211; 194.56 * x_fact**2 * y_fact + 119.79 * y_fact**3<\/p>\n<p>return [x, y][\/sourcecode]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last project I used (standalone) Python for geoprocessing. Since ArcGIS or something like that was not there to help with projecting geodata from one coordinate system to another, I wrote a function which converts well-known WGS1984\u00a0to\u00a0Swiss national grid coordinates (Swissgrid,\u00a0CH1903 LV03). Swisstopo has the\u00a0formulas\u00a0of an approximate transformation and also funtions in C#, Javascript &hellip; <a href=\"https:\/\/www.ralphstraumann.ch\/blog\/2011\/05\/projection-from-wgs1984-to-swiss-national-grid-ch1903-lv03\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Projection from WGS1984 to Swiss national grid (CH1903 LV03)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11],"tags":[52,53,92,102],"class_list":["post-419","post","type-post","status-publish","format-standard","hentry","category-snippet","tag-geo","tag-geoprocessing","tag-python","tag-software"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3pPwF-6L","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts\/419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/comments?post=419"}],"version-history":[{"count":1,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts\/419\/revisions"}],"predecessor-version":[{"id":1351,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/posts\/419\/revisions\/1351"}],"wp:attachment":[{"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/media?parent=419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/categories?post=419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ralphstraumann.ch\/blog\/wp-json\/wp\/v2\/tags?post=419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}