{"id":23291256,"url":"https://github.com/tomasjohansson/sweden_crs_transformations_4net","last_synced_at":"2025-04-06T17:45:28.342Z","repository":{"id":69668902,"uuid":"350889394","full_name":"TomasJohansson/sweden_crs_transformations_4net","owner":"TomasJohansson","description":"C#.NET library for transformation of geographic coordinates between WGS84 and the Swedish coordinate reference systems SWEREF99 and RT90","archived":false,"fork":false,"pushed_at":"2021-06-04T18:09:23.000Z","size":186,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"csharpe_SwedenCrsTransformations","last_synced_at":"2025-02-12T23:48:25.213Z","etag":null,"topics":["coordinate","coordinate-reference-system","coordinates","crs","crs-transformations","gis","net","net-library","rt90","spatial","sweden","swedish","sweref","sweref99","sweref99tm","transform","transformation","transformations","transforms","wgs84"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomasJohansson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-03-23T23:46:28.000Z","updated_at":"2024-02-01T14:24:14.000Z","dependencies_parsed_at":"2023-09-16T11:36:46.783Z","dependency_job_id":null,"html_url":"https://github.com/TomasJohansson/sweden_crs_transformations_4net","commit_stats":{"total_commits":137,"total_committers":5,"mean_commits":27.4,"dds":0.06569343065693434,"last_synced_commit":"f8b11625dd98ad10fc43619362cf633d76dd9753"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasJohansson%2Fsweden_crs_transformations_4net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasJohansson%2Fsweden_crs_transformations_4net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasJohansson%2Fsweden_crs_transformations_4net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasJohansson%2Fsweden_crs_transformations_4net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomasJohansson","download_url":"https://codeload.github.com/TomasJohansson/sweden_crs_transformations_4net/tar.gz/refs/heads/csharpe_SwedenCrsTransformations","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526675,"owners_count":20953141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coordinate","coordinate-reference-system","coordinates","crs","crs-transformations","gis","net","net-library","rt90","spatial","sweden","swedish","sweref","sweref99","sweref99tm","transform","transformation","transformations","transforms","wgs84"],"created_at":"2024-12-20T05:16:27.378Z","updated_at":"2025-04-06T17:45:28.319Z","avatar_url":"https://github.com/TomasJohansson.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sweden_crs_transformations_4net\n'sweden_crs_transformations_4net' is a C#.NET library for transforming geographic coordinates between the following three kind of CRS (Coordinate Reference Systems): WGS84, SWEREF99 and RT90.\n(13 versions of SWEREF99, and 6 versions of RT90)\n\nThe library is based on [MightyLittleGeodesy](https://github.com/bjornsallarp/MightyLittleGeodesy/) which in turn is based on a [javascript library by Arnold Andreasson](http://latlong.mellifica.se/).\n\nThe main part of 'MightyLittleGeodesy' which has been kept is the mathematical calculations in the class 'GaussKreuger.cs'.\n(although some modifications have been done in the class [GaussKreuger](https://github.com/TomasJohansson/sweden_crs_transformations_4net/blob/csharpe_SwedenCrsTransformations/SwedenCrsTransformations/MightyLittleGeodesy/Classes/GaussKreuger.cs))\n\n# NuGet release\n\nNo.  \nI have currently not released it anywhere except from here at this github repository, and currently I have no plans of releasing it at NuGet neither.  \nIf you are looking for a NuGet library for transformation of coordinates, I can instead suggest that you try using my .NET library [crsTransformations-dotnet](https://github.com/TomasJohansson/crsTransformations-dotnet) with adapters for (currently) three implementation libraries (and one of those is 'MightyLittleGeodesy').  \nThat adapter library is implemented with F# but you can use it from C# too if you want.\n\nOf course, if you are only interested in Swedish coordinate systems then you can also choose to use \n[MightyLittleGeodesy](https://github.com/bjornsallarp/MightyLittleGeodesy) (which is also [released to NuGet](https://www.nuget.org/packages/MightyLittleGeodesy/)) directly.  \nThe disadvantage (IMHO) with using 'MightyLittleGeodesy' directly is that the client API is not consistent in the sense that you need to use different classes (for WGS84, RT90, SWEREF99) \nand you can only directly transform to/from WGS84.  \nFor example if you want to transform between two SWEREF99 systems, then you have to (in your own client code) do it through an intermediate WGS84 transformation.  \nSee a code example further down below which compares the API for 'MightyLittleGeodesy' with this library 'sweden_crs_transformations_4net'.  \n\n# Ports to other programming languages\nCurrently I have ported this C#.NET library to the following programming languages and github repositories:   \nDart: [sweden_crs_transformations_4dart](https://github.com/TomasJohansson/sweden_crs_transformations_4dart)   \nTypeScript: [sweden_crs_transformations_4typescript](https://github.com/TomasJohansson/sweden_crs_transformations_4typescript)   \nJava : [sweden_crs_transformations_4jvm](https://github.com/TomasJohansson/sweden_crs_transformations_4jvm)   \n\n# Code example\nPlease note that the API is very different from the originally forked library.  \n(the only significant part that remains from the forked library is the *internal implementation* using the GaussKreuger class).  \nSee a code example further down below which compares the API for 'MightyLittleGeodesy' vs this library 'sweden_crs_transformations_4net'.\n```C#\nusing SwedenCrsTransformations;\nusing System;\nusing System.Collections.Generic;\n\n...\n\nconst double stockholmCentralStation_WGS84_latitude = 59.330231; // https://kartor.eniro.se/m/XRCfh\nconst double stockholmCentralStation_WGS84_longitude = 18.059196;\n\nCrsCoordinate stockholmWGS84 = CrsCoordinate.CreateCoordinate(\n    CrsProjection.wgs84,\n    stockholmCentralStation_WGS84_latitude,\n    stockholmCentralStation_WGS84_longitude\n);\n\nCrsCoordinate stockholmSweref99tm = stockholmWGS84.Transform(CrsProjection.sweref_99_tm);\nConsole.WriteLine(\"stockholmSweref99tm X: \" + stockholmSweref99tm.LongitudeX);\nConsole.WriteLine(\"stockholmSweref99tm Y: \" + stockholmSweref99tm.LatitudeY);\nConsole.WriteLine(\"stockholmSweref99tm 'ToString': \" + stockholmSweref99tm.ToString());\n// Output from the above:\n//stockholmSweref99tm X: 674032.357\n//stockholmSweref99tm Y: 6580821.991\n//stockholmSweref99tm 'ToString': CrsCoordinate [ Y: 6580821.991 , X: 674032.357 , CRS: SWEREF_99_TM(EPSG:3006) ]\n\nIList\u003cCrsProjection\u003e allProjections = CrsProjectionFactory.GetAllCrsProjections();\nforeach(var crsProjection in allProjections) {\n    Console.WriteLine(stockholmWGS84.Transform(crsProjection));\n}\n// Output from the above loop:\n//CrsCoordinate [ Y: 6580821.991 , X: 674032.357 , CRS: SWEREF_99_TM(EPSG:3006) ]\n//CrsCoordinate [ Y: 6595151.116 , X: 494604.69 , CRS: SWEREF_99_12_00(EPSG:3007) ]\n//CrsCoordinate [ Y: 6588340.147 , X: 409396.217 , CRS: SWEREF_99_13_30(EPSG:3008) ]\n//CrsCoordinate [ Y: 6583455.373 , X: 324101.998 , CRS: SWEREF_99_15_00(EPSG:3009) ]\n//CrsCoordinate [ Y: 6580494.921 , X: 238750.424 , CRS: SWEREF_99_16_30(EPSG:3010) ]\n//CrsCoordinate [ Y: 6579457.649 , X: 153369.673 , CRS: SWEREF_99_18_00(EPSG:3011) ]\n//CrsCoordinate [ Y: 6585657.12 , X: 366758.045 , CRS: SWEREF_99_14_15(EPSG:3012) ]\n//CrsCoordinate [ Y: 6581734.696 , X: 281431.616 , CRS: SWEREF_99_15_45(EPSG:3013) ]\n//CrsCoordinate [ Y: 6579735.93 , X: 196061.94 , CRS: SWEREF_99_17_15(EPSG:3014) ]\n//CrsCoordinate [ Y: 6579660.051 , X: 110677.129 , CRS: SWEREF_99_18_45(EPSG:3015) ]\n//CrsCoordinate [ Y: 6581507.028 , X: 25305.238 , CRS: SWEREF_99_20_15(EPSG:3016) ]\n//CrsCoordinate [ Y: 6585277.577 , X: -60025.629 , CRS: SWEREF_99_21_45(EPSG:3017) ]\n//CrsCoordinate [ Y: 6590973.148 , X: -145287.219 , CRS: SWEREF_99_23_15(EPSG:3018) ]\n//CrsCoordinate [ Y: 6598325.639 , X: 1884004.1 , CRS: RT90_7_5_GON_V(EPSG:3019) ]\n//CrsCoordinate [ Y: 6587493.237 , X: 1756244.287 , CRS: RT90_5_0_GON_V(EPSG:3020) ]\n//CrsCoordinate [ Y: 6580994.18 , X: 1628293.886 , CRS: RT90_2_5_GON_V(EPSG:3021) ]\n//CrsCoordinate [ Y: 6578822.84 , X: 1500248.374 , CRS: RT90_0_0_GON_V(EPSG:3022) ]\n//CrsCoordinate [ Y: 6580977.349 , X: 1372202.721 , CRS: RT90_2_5_GON_O(EPSG:3023) ]\n//CrsCoordinate [ Y: 6587459.595 , X: 1244251.702 , CRS: RT90_5_0_GON_O(EPSG:3024) ]\n//CrsCoordinate [ Latitude: 59.330231 , Longitude: 18.059196 , CRS: WGS84(EPSG:4326) ]\n```\n\n# API difference between the forked library 'MightyLittleGeodesy' and this library 'sweden_crs_transformations_4net'\n\nThe example below shows how to transform from a RT90 coordinate ('RT90 2.5 gon v' is the default in the below 'RT90Position' constructor) to SWEREF99 TM.\n\nCode example from the homepage of [MightyLittleGeodesy](https://github.com/bjornsallarp/MightyLittleGeodesy/):\n```C#\nRT90Position rt90Pos = new RT90Position(6583052, 1627548);\nSWEREF99Position sweRef = new SWEREF99Position(rt90Pos.ToWGS84(), SWEREF99Position.SWEREFProjection.sweref_99_tm);\n```\nCode example for doing the same transformation with this library 'sweden_crs_transformations_4net':\n```C#\nCrsCoordinate rt90Pos = CrsCoordinate.CreateCoordinate(CrsProjection.rt90_2_5_gon_v, 6583052, 1627548);\nCrsCoordinate sweRef = rt90Pos.Transform(CrsProjection.sweref_99_tm);\n```\nThe RT90 (2,5 gon V) coordinate used in the above example:\n```Text\nhttps://kartor.eniro.se/m/3w33L\nWGS84 decimal (lat, lon)        59.348915, 18.047319\nRT90 (northing, easting)        6583052, 1627548\nSWEREF99 TM (northing, easting) 6582870, 673262\n```\n\n# Accuracy of the transformations\n\nThe transformations have been verified by using coordinates from a test file \"swedish_crs_coordinates.csv\".  \nThat test file were copied from another project of mine which had created it by using six different Java implementations of transformations.  \nSee these URL's below for that file and the Java code that created it:  \n[https://github.com/TomasJohansson/crsTransformations/ ... /swedish_crs_coordinates.csv](https://github.com/TomasJohansson/crsTransformations/blob/a1da6c74daf040a521beb32f9f395124ffe76aa6/crs-transformation-adapter-test/src/test/resources/generated/swedish_crs_coordinates.csv  )   \n[https://github.com/TomasJohansson/crsTransformations/ ...  /CoordinateTestDataGeneratedFromEpsgDatabaseTest.java (method createFileWithTransformationResultsForCoordinatesInSweden())](https://github.com/TomasJohansson/crsTransformations/blob/173ba6c35f045ac906da5b28dfa8bbff97d037fb/crs-transformation-adapter-test/src/test/java/com/programmerare/com/programmerare/testData/CoordinateTestDataGeneratedFromEpsgDatabaseTest.java#L671)\n\nWhen I had forked 'MightyLittleGeodesy' I created a test method which asserted 108 transformations from the 18 data rows in that file.  \nSee the the test class 'TransformingCoordinatesFromFileTest.cs' and the class 'Transformer' (which uses the original MightyLittleGeodesy classes 'SWEREF99Position', RT90Position', and 'WGS84Position' for the transformations, in [git commit 135e54](https://github.com/TomasJohansson/sweden_crs_transformations_4net/commit/135e543dc8ae7fd7b8c7be9fc0f034896daea7b4).  \nLater versions of [Transformer](https://github.com/TomasJohansson/sweden_crs_transformations_4net/blob/csharpe_SwedenCrsTransformations/SwedenCrsTransformations/Transformation/Transformer.cs) does **not** use those three 'Position' subclasses at all but they are instead using the class 'GaussKreuger' (from 'MightyLittleGeodesy') from within two [implementations of a 'TransformStrategy' interface](https://github.com/TomasJohansson/sweden_crs_transformations_4net/tree/csharpe_SwedenCrsTransformations/SwedenCrsTransformations/Transformation).    \nRegression testing have been done continously by using the above mentioned 'TransformingCoordinatesFromFileTest.cs'.  \n\n\n# License\n\nMIT.   \n'SwedenCrsTransformations' started as a fork of 'MightyLittleGeodesy' and it is licensed with the MIT license just like 'MightyLittleGeodesy' (see below).  \n[License text for 'sweden_crs_transformations_4net'](https://github.com/TomasJohansson/sweden_crs_transformations_4net/blob/csharpe_SwedenCrsTransformations/LICENSE)\n\n# License for the forked repository [MightyLittleGeodesy](https://github.com/bjornsallarp/MightyLittleGeodesy/)\n\nThe text below has been copied from the above webpage (the forked repository):\n\u003e The calculations in this library is based on the excellent javascript library by Arnold Andreasson which is published under the Creative Commons license. However, as agreed with mr Andreasson, MightyLittleGeodesy is now licensed under the MIT license.\n\nThe text below has been copied from [one of the source files for MightyLittleGeodesy](https://github.com/bjornsallarp/MightyLittleGeodesy/blob/83491fc6e7454f5d90d792610b317eca7a332334/MightyLittleGeodesy/Classes/GaussKreuger.cs).\n```C#\n/*\n * MightyLittleGeodesy \n * RT90, SWEREF99 and WGS84 coordinate transformation library\n * \n * Read my blog @ http://blog.sallarp.com\n * \n * \n * Copyright (C) 2009 Björn Sållarp\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this \n * software and associated documentation files (the \"Software\"), to deal in the Software \n * without restriction, including without limitation the rights to use, copy, modify, \n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to \n * permit persons to whom the Software is furnished to do so, subject to the following \n * conditions:\n * \n * The above copyright notice and this permission notice shall be included in all copies or \n * substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING \n * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND \n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, \n * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n ```\n # Swedish coordinate reference systems\nThere are two kind of national CRS being used in Sweden:   \nThe old [RT90](https://www.lantmateriet.se/sv/Kartor-och-geografisk-information/gps-geodesi-och-swepos/Referenssystem/Tvadimensionella-system/RT-90/) (six versions for different local regions)    \nThe new [SWEREF99](https://www.lantmateriet.se/sv/Kartor-och-geografisk-information/gps-geodesi-och-swepos/referenssystem/tvadimensionella-system/sweref-99-projektioner/) (thirteen versions, one for the national \"TM\" and twelve local regions)    \n\nThe above links are for pages in Swedish at the website for [Lantmäteriet](https://en.wikipedia.org/wiki/Lantm%C3%A4teriet) which is a swedish authority for mapping.\n\n[https://www.lantmateriet.se/en/about-lantmateriet/about-lantmateriet/](https://www.lantmateriet.se/en/about-lantmateriet/about-lantmateriet/)   \nQuote from the above URL:\n```Text\nWe map the country, demarcate boundaries and help guarantee secure ownership of Sweden’s real property.   \nYou can get more information and documentation on Sweden’s geography and real properties from us.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasjohansson%2Fsweden_crs_transformations_4net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasjohansson%2Fsweden_crs_transformations_4net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasjohansson%2Fsweden_crs_transformations_4net/lists"}