ArcGIS中的投影和坐标转换
ArcGIS中的投影和坐標(biāo)轉(zhuǎn)換
1? ArcGIS中坐標(biāo)系統(tǒng)的定義
一般情況下地理數(shù)據(jù)庫(如Personal GeoDatabase的 Feature DataSet 、Shape File等)在創(chuàng)建時都具有空間參考的屬性,空間參考定義了該數(shù)據(jù)集的地理坐標(biāo)系統(tǒng)或投影坐標(biāo)系統(tǒng),沒有坐標(biāo)系統(tǒng)的地理數(shù)據(jù)在生產(chǎn)應(yīng)用過程中是毫無意義的,但由于在數(shù)據(jù)格式轉(zhuǎn)換、轉(zhuǎn)庫過程中可能造成坐標(biāo)系統(tǒng)信息丟失,或創(chuàng)建數(shù)據(jù)庫時忽略了坐標(biāo)系統(tǒng)的定義,因此需要對沒有坐標(biāo)系統(tǒng)信息的數(shù)據(jù)集進(jìn)行坐標(biāo)系統(tǒng)定義。
坐標(biāo)系統(tǒng)的定義是在不改變當(dāng)前數(shù)據(jù)集中特征X Y值的情況下對該數(shù)據(jù)集指定坐標(biāo)系統(tǒng)信息。
操作方法:運行ArcGIS9中的ArcMap,打開ArcToolBox,打開 Data Management Tools ->Projections and Transformations->Define Projection 項打開坐標(biāo)定義對話框。介下來在Input DataSet or Feature Class欄中輸入或點擊旁邊的按鈕選擇相應(yīng)的DataSet或Feature Class;在Coordinate System欄中輸入或點擊旁邊的按鈕選擇需要為上述DataSet或Feature定義的坐標(biāo)系統(tǒng)。最后點OK鍵即可。
例如 某點狀shape文件中 某點P的坐標(biāo)為? X 112.2? Y 43.3 ,且該shape文件沒有帶有相應(yīng)的Prj文件,即沒有空間參考信息,也不知道X Y 的單位。通過坐標(biāo)系統(tǒng)定義的操作定義其為Beijing1954坐標(biāo),那么點P的信息是東經(jīng)112.2度 北緯43.3度。
2? ArcGIS中的投影方法
投影的方法可以使帶某種坐標(biāo)信息數(shù)據(jù)源進(jìn)行向另一坐標(biāo)系統(tǒng)做轉(zhuǎn)換,并對源數(shù)據(jù)中的X和Y值進(jìn)行修改。我們生產(chǎn)實踐中一個典型的例子是利用該方法修正某些舊地圖數(shù)據(jù)中X,Y值前加了帶數(shù)和分帶方法的數(shù)值。
操作方法:運行ArcGIS9中的ArcMap,打開ArcToolBox,打開 Data Management Tools ->Projections and Transformations->Feature->Project 項打開投影對話框。在Input DataSet or Feature Class欄中輸入或點擊旁邊的按鈕選擇相應(yīng)的DataSet或Feature Class(帶有空間參考),Output DataSet or Feature Class欄中輸入或點擊旁邊的按鈕選擇目標(biāo)DataSet或Feature Class,在Output Coordinate System 欄中輸入或點擊旁邊的按鈕選擇目標(biāo)數(shù)據(jù)的坐標(biāo)系統(tǒng)。最后點OK鍵即可。
例如 某點狀shape文件中 某點P的坐標(biāo)為? X 40705012? Y 3478021 ,且該shape文件坐標(biāo)系統(tǒng)為中央為東經(jīng)120度的高斯克呂格投影,在數(shù)據(jù)使用過程中為了將點P的值改為真實值X 705012? Y478021,首先將源數(shù)據(jù)的投影參數(shù)中False_Easting和False_Northing值分別加上40000000和3000000作為源坐標(biāo)系統(tǒng),修改參數(shù)前的坐標(biāo)系統(tǒng)作為投影操作的目標(biāo)坐標(biāo)系統(tǒng),然后通過投影操作后生成一新的Shape文件,且與源文件中點P對應(yīng)的點的坐標(biāo)為X 705012? Y478021。
3? 編程實現(xiàn)坐標(biāo)轉(zhuǎn)換和投影
3.1 矢量數(shù)據(jù)投影和坐標(biāo)轉(zhuǎn)換
相關(guān)接口
3.1.1 IGeometry.Project方法
該方法聲明如下: (C#語法)
public void Project (
????ISpatialReference newReferenceSystem
);
該方法對實現(xiàn)Igeoemtry的對象進(jìn)行投影操作, 參數(shù)為目標(biāo)空間參考.以下代碼中實現(xiàn)了對Point對象從一個空間參考到另一個空間參考的投影操作:
//Create Spatial Reference Factory
????? ??????ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
??????????? ISpatialReference sr1;
??????????? //GCS to project from
????????????IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983);
??????????? sr1 = gcs;
??????????? sr1.SetFalseOriginAndUnits(-180, -90, 1000000);
??????????? //Projected Coordinate System to project into
??????????? IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983N_AmericaLambert);
??????????? pcs.SetFalseOriginAndUnits(0, 0, 1000);
??????????? ISpatialReference sr2;
??????????? sr2 = pcs;
??????????? //Point to project
??????????? IPoint point = new PointClass() as IPoint;
??????????? point.PutCoords(-117.17, 34.06);
??????????? //Geometry Interface to do actual project
??????????? IGeometry geometry;
??????????? geometry = point;
??????????? geometry.SpatialReference = sr1;
??????????? geometry.Project(sr2);
??????????? point = geometry as IPoint;
??????????? double x;
??????????? double y;
??????????? point.QueryCoords(out x, out y);
??????????? Debug.Print("X: " + x.ToString());
??????????? Debug.Print("Y: " + y.ToString());
IGeometry接口的Project方法提供的投影操作實現(xiàn)了最基本的坐標(biāo)轉(zhuǎn)換功能. 實際數(shù)據(jù)處理過程中, 比較明確數(shù)據(jù)轉(zhuǎn)換前后空間參考信息情況下一般用此方法作坐標(biāo)轉(zhuǎn)換,不同投影帶之間的坐標(biāo)轉(zhuǎn)換就是一個典型.
3.1.2 ITransform2D接口
ITransform2D接口不僅提供了圖形平移, 旋轉(zhuǎn)和縮放,還提供了更加強大的坐標(biāo)轉(zhuǎn)換方法Transform. 其定義如下:(C#語法)
public void Transform (
????esriTransformDirection direction,
????ITransformation transformation
);
在該方法中, 參數(shù)direction是轉(zhuǎn)換方向, transformation是一個Itransformation接口, 而Itransformation接口由很多類實現(xiàn),這意味著不同的實現(xiàn)類,所包含的坐標(biāo)轉(zhuǎn)換數(shù)學(xué)公式是不一的, 這里面包括二次多項式轉(zhuǎn)換(AffineTransformation2D), AbridgedMolodensky轉(zhuǎn)換(AbridgedMolodenskyTransformation)等。每一種實現(xiàn)類的轉(zhuǎn)換方法這里不再贅述,可參照ArcObjects聯(lián)機幫助獲得更詳細(xì)的信息,下面舉例來說明該方法的使用:(Delphi 代碼)
procedure Transform_(FromPtColl, ToPtColl: IPointCollection; pGeo as IGeometry);
var
? pAffineTransformation2D: IAffineTransformation2D;
? ControlPtCnt: integer;
? FormPtArray: array of IPoint;
? ToPtArray: array of IPoint;
? i: integer;?
??pTransform2D: ITransform2D;
begin
? //判斷給定的控制點是否合法
? if FromPtColl.PointCount <> ToPtColl.PointCount then
??? begin
????? //控制點不成對錯誤
????? exit;
??? end;
? if FromPtColl.PointCount < 4 then
??? begin
????? //控制點不能少于4個
????? exit;
??? end;
? ControlPtCnt := FromPtColl.PointCount;
? SetLength(FormPtArray, ControlPtCnt);
? SetLength(ToPtArray, ControlPtCnt);
? for i := 0 to ControlPtCnt -1 do
??? begin
????? FormPtArray[i] := CoPoint.Create as IPoint;
????? FormPtArray[i].PutCoords(FromPtColl.Point[i].X,? FromPtColl.Point[i].Y);
????? ToPtArray[i] := CoPoint.Create as IPoint;
????? ToPtArray[i].PutCoords(ToPtColl.Point[i].X,? ToPtColl.Point[i].Y);
??? end;
? //創(chuàng)建? AffineTransformation2D 對象
? pAffineTransformation2D := CoAffineTransformation2D.Create as IAffineTransformation2D;?
??//設(shè)置控制點信息
? pAffineTransformation2D.DefineFromControlPoints(ControlPtCnt, FormPtArray[0], ToPtArray[0]);?
??//轉(zhuǎn)到ITransform2D接口
?pTransform2D := pGeo as ITransform2D;
? //坐標(biāo)轉(zhuǎn)換
? pTransform2d.Transform(esriTransformForward, pAffineTransformation2D);
end;
?
ITransform接口較Igeoemtry提供了更加豐富的坐標(biāo)轉(zhuǎn)換方法。
3.2 影像數(shù)據(jù)糾正。
影像數(shù)據(jù)糾正可以通過IrasterGeometryProc接口實現(xiàn)。該接口提供了影像Clip, Filp, Merge, Mirror以及Mosaic等操作。如果通過控制點的方式對影像進(jìn)行糾正處理可以通過該接口的wrap方法。該方法聲明如下:(C#語法)
public void Warp (
????IPointCollection sourceControlPoints,
????IPointCollection targetControlPoints,
????esriGeoTransTypeEnum transformType,
????IRaster ipRaster
);
參數(shù) sourceControlPoints和targetControlPoint定義了控制點信息, transformType定義了坐標(biāo)轉(zhuǎn)換方法, ipRaster是需要轉(zhuǎn)換的Raster對象. 以下代碼是該接口使用的例子:
public static void GeoreferenceRaster(IRasterDataset2 rasterDataset, IPointCollection sourcePoints, IPointCollection targetPoints)
{
? //this sample show how to georeference a raster using control points
? // sourcePoints: represents source control points
? // targetPoints: represents target control points? IRasterGeometryProc rasterPropc = new RasterGeometryProcClass();
? IRaster raster = rasterDataset.CreateDefaultRaster();? //set the transformatin
? rasterPropc.Warp(sourcePoints, targetPoints, esriGeoTransTypeEnum.esriGeoTransPolyOrder1, raster);? //There are two ways to get the georeferenced result: to save the transformation with the input raster dataset
? rasterPropc.Register(raster);? //or save to another new raster dataset
? rasterPropc.Rectify(@"c:\temp\georeferencing_output.img", "IMAGINE Image", raster);
}
需要注意的是當(dāng)選擇不同的轉(zhuǎn)換類型時(參數(shù)transformType取值不同時), 對控制點的對數(shù)也有不同的要求. 這個可以參照聯(lián)機幫助中的詳細(xì)說明.
此外, 使用IrasterGeometryProc.Wrap方法, 會略微改變影像圖的色彩值, 當(dāng)對一幅影像圖前后轉(zhuǎn)換作對比時會發(fā)現(xiàn)這種色彩的變化情況.
個人認(rèn)為,ArcGIS對影像圖的處理功能較其他一些專業(yè)影像處理軟件來講,還是稍顯遜色了些.?
轉(zhuǎn)載于:https://www.cnblogs.com/zany-hui/articles/1272568.html
總結(jié)
以上是生活随笔為你收集整理的ArcGIS中的投影和坐标转换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 您是否也想过让你的电脑百毒不侵呢!
- 下一篇: PING 命令测试