我正在尝试将WGS84系统中的lat/lon坐标重新投影到SIRGAS 2000 coord系统中的UTM坐标。使用GDAL,我首先将已知的UTM坐标更改为相同坐标系统(29 N)中的lat/lon对应项,以检查我编写的代码是否正确(这里省略了错误检查)。
现在,从
如您所见,原始的
在Google地图中,我们可以看到两点之间有27米的差距(原始点由圆圈表示,我的“反向重投影”点由匕首表示)。
OGRSpatialReference monUtm;
monUtm.SetWellKnownGeogCS("WGS84");
monUtm.SetUTM(29, true);
OGRSpatialReference monGeo;
monGeo.SetWellKnownGeogCS("WGS84");
OGRCoordinateTransformation* coordTrans = OGRCreateCoordinateTransformation(&monUtm, &monGeo);
double x = 621921.3413490148;
double y = 4794536.070196861;
int reprojected = coordTrans->Transform(1, &x, &y);
// If OK, print the coords.
delete coordTrans;
coordTrans = OGRCreateCoordinateTransformation(&monGeo, &monUtm);
reprojected = coordTrans->Transform(1, &x, &y);
// If OK, Print the coords.
delete coordTrans;
这些坐标 621921.3413490148, 4794536.070196861
对应于加利西亚北部的蒙塞洛斯地区。前后转换似乎是正确的:纬度/经度坐标是正确的,当回投影到UTM时,我得到了与原始坐标相同的结果:
UTM: 621921.34135 , 4794536.0702
Lat/lon: 43.293779579 , -7.4970160261
Back to UTM: 621921.34135 , 4794536.0702
现在,从
WGS84 经纬度
转换到 SIRGAS 2000 UTM
:// Rodovia dos Tamoios, Brazil:
// - UTM -> 23 S
// - WGS 84 -> EPSG:32723
// - SIRGAS 2000 -> EPSG:31983
OGRSpatialReference wgs;
wgs.SetWellKnownGeogCS("WGS84");
OGRSpatialReference sirgas;
sirgas.importFromEPSG(31983);
coordTrans = OGRCreateCoordinateTransformation(&wgs, &sirgas);
double x = -23.57014667;
double y = -45.49159617;
reprojected = coordTrans->Transform(1, &x, &y);
// If OK, print results
delete coordTrans;
coordTrans = OGRCreateCoordinateTransformation(&sirgas, &wgs);
reprojected = coordTrans->Transform(1, &x, &y);
// If OK, print results.
这不会产生相同的结果:
WGS84 Lat/Lon input: -23.57014667 , -45.49159617
SIRGAS 2000 UTM output: 2173024.0216 , 4734004.2131
Back to WGS84 Lat/Lon: -23.570633824 , -45.491627598
如您所见,原始的
WGS84纬度/经度
和返回WGS84纬度/经度
坐标并不完全相同,与第一个测试用例不同。此外,UTM x-coord
有7位数字(我认为它只限于6位(?))。在Google地图中,我们可以看到两点之间有27米的差距(原始点由圆圈表示,我的“反向重投影”点由匕首表示)。
最后一个问题:我重投影的方式正确吗?如果是,为什么第二个测试用例中的重投影存在27米的差异?