我正在嘗試將WGS84
系統中的lat/lon
座標重新投影到SIRGAS 2000
座標系中的座標UTM
。使用GDAL庫重新注入座標
使用GDAL
,我開始改變已知UTM座標緯度/經度對應相同座標系(29 N),只是爲了檢查我寫正確的代碼(我忽略錯誤檢查這裏):
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
correspond to the Moncelos region in northern Galicia。第四和迴轉型似乎工作是正確的:經/緯度coordiantes是正確的和屬於投射回UTM的時候,我得到相同的原件:
UTM: 621921.34135 , 4794536.0702
Lat/lon: 43.293779579 , -7.4970160261
Back to UTM: 621921.34135 , 4794536.0702
現在,從WGS84 lat/long
重新投影到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 lat/lon
和back-to_WGS84 lat/lon
座標不完全相同,不像第一個測試案例。此外,UTM x-coord
有7位數字(我認爲它被限制爲6(?))。
In Google Maps,我們可以看到,有兩個點27之間米的差異(原點由圈代表。我的「後重新投影」點由匕首表示)。
最後,問題是:我在做reprojection權嗎?如果是這樣,爲什麼第二個測試案例中重新投射之間有27米的差距?
謝謝!有效!由於重投是'成功'的,我沒有意識到座標的順序是錯誤的。 – 2015-02-12 08:41:27