|
|
arcgis 投影变换与坐标转换研究
1 ArcGIS中的投影方法
投影的方法可以使带某种坐标信息数据源进行向另一坐标系统做转换,并对源数据中的X和Y值进行修改。我们生产实践中一个典型的例子是利用该方法修正某些旧地图数据中X,Y值前加了带数和分带方法的数值。 字串7
操作方法:运行ArcGIS9中的ArcMap,打开ArcToolBox,打开 Data Management Tools -> rojections 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 := CoPoint.Create as IPoint; 字串9 FormPtArray.PutCoords(FromPtColl.Point.X, FromPtColl.Point.Y); 字串9 ToPtArray := CoPoint.Create as IPoint; 字串5 ToPtArray.PutCoords(ToPtColl.Point.X, ToPtColl.Point.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提供了更加丰富的坐标转换方法。
字串9
3.2 影像数据纠正。
影像数据纠正可以通过IrasterGeometryProc接口实现。该接口提供了影像Clip, Filp, Merge, Mirror以及Mosaic等操作。如果通过控制点的方式对影像进行纠正处理可以通过该接口的wrap方法。该方法声明如下 C#语法)
字串6
public void Warp ( 字串1 IPointCollection sourceControlPoints, 字串8 IPointCollection targetControlPoints, 字串4 esriGeoTransTypeEnum transformType, 字串5 IRaster ipRaster 字串9 );
字串5
参数 sourceControlPoints和targetControlPoint定义了控制点信息, transformType定义了坐标转换方法, ipRaster是需要转换的Raster对象. 以下代码是该接口使用的例子:
字串6
public static void GeoreferenceRaster(IRasterDataset2 rasterDataset, IPointCollection sourcePoints, IPointCollection targetPoints) 字串9 { 字串2 //this sample show how to georeference a raster using control points 字串7 // sourcePoints: represents source control points 字串6 // targetPoints: represents target control points IRasterGeometryProc rasterPropc = new RasterGeometryProcClass(); 字串6 IRaster raster = rasterDataset.CreateDefaultRaster(); //set the transformatin 字串2 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 字串7 rasterPropc.Register(raster); //or save to another new raster dataset 字串9 rasterPropc.Rectify(@"c:\temp\georeferencing_output.img", "IMAGINE Image", raster); 字串3 } 字串1 需要注意的是当选择不同的转换类型时(参数transformType取值不同时), 对控制点的对数也有不同的要求. 这个可以参照联机帮助中的详细说明. 字串6
此外, 使用IrasterGeometryProc.Wrap方法, 会略微改变影像图的色彩值, 当对一幅影像图前后转换作对比时会发现这种色彩的变化情况. 字串1
个人认为,ArcGIS对影像图的处理功能较其他一些专业影像处理软件来讲,还是稍显逊色了些. |
评分
-
查看全部评分
|