Converting ViennaGIS to WGS84 coordinates
Converting ViennaGIS Gauss-Krüger M 34 MGI Austria GK East coordinates to Google WGS84 coordinates using EPSG code 31256.

In a recent project, I had to convert coordinates from ViennaGIS Gauss-Krüger M 34 MGI Austria GK East to Google WGS84 using EPSG code 31256. The goal was to show pins on Google Maps or Leaflet for objects and locations supplied by ViennaGIS.
Unfortunately, ViennaGIS uses a Gauss-Krüger M 34 projection, which most map SDKs can't handle. So I had to convert the coordinates to Google’s coordinate system first. I used the libraries proj4j and proj4js, the Java and JavaScript ports of the PROJ library.
The code snippets below show how to convert ViennaGIS GK34 coordinates to WGS84 in Kotlin and JavaScript.
Kotlin
// Kotlin version
// Maven dependency:
// <dependency>
// <groupId>org.locationtech.proj4j</groupId>
// <artifactId>proj4j</artifactId>
// <version>1.0.0</version>
// </dependency>
package at.agsolutions
import at.agsolutions.Gk34Dto
import at.agsolutions.Wgs84Dto
import org.locationtech.proj4j.CRSFactory
import org.locationtech.proj4j.CoordinateTransformFactory
import org.locationtech.proj4j.ProjCoordinate
class Gk34ToWgs84CoordinatesTransformer {
private val coordinateTranformFactory = CoordinateTransformFactory()
/**
* EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich
* Cadastral plan in Eastern Austria (Irenental)
* see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria
*/
private val transformGk34ToWgs84 = coordinateTranformFactory.createTransform(
/* GK34 */ CRSFactory().createFromName("epsg:31256"), /* WGS84 */ CRSFactory().createFromName("epsg:4326")
)
fun transform(gk34: Gk34Dto): Wgs84Dto {
val result = ProjCoordinate()
transformGk34ToWgs84.transform(ProjCoordinate(gk34.x.toDouble(), gk34.y.toDouble()), result)
return Wgs84Dto(result.y.toBigDecimal(), result.x.toBigDecimal())
}
}JavaScript
// JS version
// package.json contents:
// {
// "name": "vienna-gis-to-wgs84",
// "version": "1.0.0",
// "main": "index.js",
// "dependencies": {
// "epsg": "^0.5.0",
// "proj4": "^2.5.0"
// }
// }
const proj4 = require('proj4');
const epsg = require('epsg');
/**
* EPSG code 31256 = MGI Austria GK East, Gauss-Krüger M 34 (DKM), Greenwich
* Cadastral plan in Eastern Austria (Irenental)
* see https://www.esri-austria.at/service/projektionen-oesterreich/ and https://de.wikipedia.org/wiki/Datum_Austria
*/
const gk34ToWgs84 = coordinates => {
const result = proj4(epsg['EPSG:31256'], 'WGS84', Object.assign({}, coordinates));
console.log(coordinates.x + ', ' + coordinates.y + ' = ' + result.y + ', ' + result.x);
};
gk34ToWgs84({ x: 2950.77, y: 341754.91 });
gk34ToWgs84({ x: 5860.5, y: 342140.71 });
gk34ToWgs84({ x: -9587.52, y: 344411.47 });Got a similar project in mind?
In a free initial call we look at your situation and tell you what's realistic and what the next step looks like.



