转载 ArcGIS投影转换与坐标转换研究

转载地址: http://www.gispark.com/html/develop/arcgis%20engine/2007/1123/1884.html

 

arcgis 投影变换与坐标转换研究

1 ArcGIS中的投影方法
投影的方法可以使带某种坐标信息数据源进行向另一坐标系统做转换,并对源数据中的X和Y值进行修改。我们生产实践中一个典型的例子是利用该方法修正某些旧地图数据中X,Y值前加了带数和分带方法的数值。 字串7

操作方法:运行ArcGIS9中的ArcMap,打开ArcToolBox,打开 Data Management Tools ->Projections and Transformations->Feature->Project 项 打开投影对话框。在Input DataSet or Feature Class栏中输入或点击旁边的按钮选择相应的DataSet或Feature Class(带有空间参考),Output DataSet or Feature Class栏中输入或点击旁边的按钮选择目标DataSet或Feature Class,在Output Coordinate System 栏中输入或点击旁边的按钮选择目标数据的坐标系统。最后点OK键即可。 字串9

例如 某点状shape文件中 某点P的坐标为  X 40705012  Y 3478021 ,且该shape文件坐标系统为中央为东经120度的高斯克吕格投影,在数据使用过程中为了将点P的值改为真实值X 705012  Y478021,首先将源数据的投影参数中False_Easting和False_Northing值分别加上40000000和3000000作为源坐标系统,修改参数前的坐标系统作为投影操作的目标坐标系统,然后通过投影操作后生成一新的Shape文件,且与源文件中点P对应的点的坐标为X 705012  Y478021。

字串6

 

2 ArcGIS中坐标系统的定义
一般情况下地理数据库(如Personal GeoDatabase的 Feature DataSet 、Shape File等)在创建时都具有空间参考的属性,空间参考定义了该数据集的地理坐标系统或投影坐标系统,没有坐标系统的地理数据在生产应用过程中是毫无意义的,但由于在数据格式转换、转库过程中可能造成坐标系统信息丢失,或创建数据库时忽略了坐标系统的定义,因此需要对没有坐标系统信息的数据集进行坐标系统定义。

字串7

 

坐标系统的定义是在不改变当前数据集中特征X Y值的情况下 对该数据集指定坐标系统信息。

字串3

 

操作方法:运行ArcGIS9中的ArcMap,打开ArcToolBox,打开 Data Management Tools ->Projections and Transformations->Define Projection 项 打开坐标定义对话框。介下来在Input DataSet or Feature Class栏中输入或点击旁边的按钮选择相应的DataSet或Feature Class;在Coordinate System栏中输入或点击旁边的按钮选择需要为上述DataSet或Feature定义的坐标系统。最后点OK键即可。 字串7

例如 某点状shape文件中 某点P的坐标为  X 112.2  Y 43.3 ,且该shape文件没有带有相应的Prj文件,即没有空间参考信息,也不知道X Y 的单位。通过坐标系统定义的操作定义其为Beijing1954坐标,那么点P的信息是东经112.2度 北纬43.3度。

字串9

 

3  编程实现坐标转换和投影
3.1 矢量数据投影和坐标转换
相关接口

字串5

 

3.1.1 IGeometry.Project方法 字串8

该方法声明如下

字串8

 

public void Project ( 字串2

    ISpatialReference newReferenceSystem 字串7

); 字串8

该方法对实现Igeoemtry的对象进行投影操作, 参数为目标空间参考.以下代码中实现了对Point对象从一个空间参考到另一个空间参考的投影操作:

字串9

 

//Create Spatial Reference Factory 字串4

            ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass(); 字串9

            ISpatialReference sr1;

字串1

 

            //GCS to project from 字串3

            IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983);

字串9

 

            sr1 = gcs;

字串4

 

            sr1.SetFalseOriginAndUnits(-180, -90, 1000000);

字串9

 

            //Projected Coordinate System to project into 字串6

            IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983N_AmericaLambert); 字串2

            pcs.SetFalseOriginAndUnits(0, 0, 1000);

字串3

 

            ISpatialReference sr2;

字串2

 

            sr2 = pcs; 字串5

            //Point to project 字串8

            IPoint point = new PointClass() as IPoint;

字串7

 

            point.PutCoords(-117.17, 34.06); 字串8

            //Geometry Interface to do actual project 字串4

            IGeometry geometry;

字串8

 

            geometry = point; 字串8

            geometry.SpatialReference = sr1;

字串8

 

            geometry.Project(sr2); 字串7

            point = geometry as IPoint;

字串1

 

            double x; 字串7

            double y; 字串3

            point.QueryCoords(out x, out y);

字串1

 

            Debug.Print("X: " + x.ToString());

字串8

 

            Debug.Print("Y: " + y.ToString());

字串5

 

IGeometry接口的Project方法提供的投影操作实现了最基本的坐标转换功能. 实际数据处理过程中, 比较明确数据转换前后空间参考信息情况下一般用此方法作坐标转换,不同投影带之间的坐标转换就是一个典型. 字串9

3.1.2 ITransform2D接口

ITransform2D接口不仅提供了图形平移, 旋转和缩放,还提供了更加强大的坐标转换方法Transform. 其定义如下:C#语法) 字串2

public void Transform (
字串9
    esriTransformDirection direction,
字串8
    ITransformation transformation 字串2 

);

字串4

 

在该方法中, 参数direction是转换方向, transformation是一个Itransformation接口, Itransformation接口由很多类实现,这意味着不同的实现类,所包含的坐标转换数学公式是不一的, 这里面包括二次多项式转换(AffineTransformation2D), AbridgedMolodensky转换(AbridgedMolodenskyTransformation)等。每一种实现类的转换方法这里不再赘述,可参照ArcObjects联机帮助获得更详细的信息,下面举例来说明该方法的使用:(Delphi 代码)

字串6

 

procedure Transform_(FromPtColl, ToPtColl: IPointCollection; pGeo as IGeometry); 字串3 
var 字串1 
 pAffineTransformation2D: IAffineTransformation2D; 字串5 
 ControlPtCnt: integer; 字串2 
 FormPtArray: array of IPoint;

字串1

 ToPtArray: array of IPoint;

字串3

 i: integer; 
字串9
  pTransform2D: ITransform2D; 

字串6

begin
字串3
 //判断给定的控制点是否合法 字串5 
 if FromPtColl.PointCount <> ToPtColl.PointCount then

字串7

    begin 字串9 
      //控制点不成对错误 字串8 
      exit;
字串1
    end;

字串3

 if FromPtColl.PointCount < 4 then

字串9

    begin
字串8
      //控制点不能少于4个

字串7

      exit;
字串4
    end;

字串3

 ControlPtCnt := FromPtColl.PointCount; 字串6 
 SetLength(FormPtArray, ControlPtCnt);
字串1
 SetLength(ToPtArray, ControlPtCnt); 字串8 
 for i := 0 to ControlPtCnt -1 do

字串3

    begin 字串4 
      FormPtArray[i] := CoPoint.Create as IPoint; 字串9 
      FormPtArray[i].PutCoords(FromPtColl.Point[i].X, FromPtColl.Point[i].Y); 字串9 
      ToPtArray[i] := CoPoint.Create as IPoint;
字串5
      ToPtArray[i].PutCoords(ToPtColl.Point[i].X, ToPtColl.Point[i].Y); 字串4 
    end;
字串7
 //创建 AffineTransformation2D 对象
字串9
 pAffineTransformation2D := CoAffineTransformation2D.Create as IAffineTransformation2D;  字串8 
  //设置控制点信息
字串6
 pAffineTransformation2D.DefineFromControlPoints(ControlPtCnt, FormPtArray[0], ToPtArray[0]);  字串1 
  //转到ITransform2D接口

字串1

  pTransform2D := pGeo as ITransform2D; 字串1 
 //坐标转换
字串1
 pTransform2d.Transform(esriTransformForward, pAffineTransformation2D);
字串8
end;
字串8
 
字串6

ITransform接口较Igeoemtry提供了更加丰富的坐标转换方法。

 

 

posted on 2009-01-20 10:38  冉冉升起  阅读(129)  评论(0)    收藏  举报

导航