ProjNet4GeoAPI
ProjNet4GeoAPI copied to clipboard
Transform generates Z coordinate
I'm trying to convert coordinates from 31370 (Lambert72) to 4326 (Wgs84). My input has XY and parsing to WKT gives me the following result;
POINT (107984.0377 159720.7285)
The output after conversion however is giving me XYZ and the following WKT;
POINT (3.773414706860081 50.746493659745141 42.610120716504753)
I would expect something XY. Is there supposed to be a Z coördinate? Am I doing something wrong? Is there a way of not getting a Z coordinate?
Repro code below;
var geometry = new Point(107984.0377, 159720.7285);
var source = new CoordinateSystemFactory()
.CreateFromWkt("PROJCS[\"Belge 1972 / Belgian Lambert 72\",GEOGCS[\"Belge 1972\",DATUM[\"Reseau_National_Belge_1972\",SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]],TOWGS84[-106.869,52.2978,-103.724,0.3366,-0.457,1.8422,-1.2747],AUTHORITY[\"EPSG\",\"6313\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4313\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"standard_parallel_1\",51.16666723333333],PARAMETER[\"standard_parallel_2\",49.8333339],PARAMETER[\"latitude_of_origin\",90],PARAMETER[\"central_meridian\",4.367486666666666],PARAMETER[\"false_easting\",150000.013],PARAMETER[\"false_northing\",5400088.438],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH],AUTHORITY[\"EPSG\",\"31370\"]]");
var lambertToWgs84Transformation = new CoordinateTransformationFactory()
.CreateFromCoordinateSystems(source, GeographicCoordinateSystem.WGS84);
var preWkt = geometry.AsText();
var converted = GeometryTransform.TransformGeometry(geometry.Factory, geometry, lambertToWgs84Transformation.MathTransform);
var postWkt = converted.AsText();
Because of the TOWGS84 string the transformation between the spheroids goes via cartesian 3D geocentric coordinates. When transforming back to WGS84 you will end up with an altitude value as well that should correspond to the height difference between the spheroids at that point.