ArcGIS Engine基础(31)之使用仿射变换对矢量数据进行空间校正

        在生产数据过程中,因每个工程项目都可能有自己的施工坐标系,难免会产生数据提供方与数据使用方采用的坐标系不一致,造成数据在不同坐标系下存在一定偏移、旋转、缩放等,为了让数据能够在新坐标系准确定位,需要进行空间校正,空间校正是针对矢量图的,栅格配准是针对栅格影像的,arcgis中提供的空间校正的方法有:仿射变换、投影变换、相似变换、橡皮页变换等。

        本文介绍的是仿射变换法,仿射变换是空间直角坐标变换的一种,它是一种二维坐标到二维坐标之间的线性变换,保持二维图形的“平直线”和“平行性”,其可以通过一系列的原子变换的复合来实现,包括平移(Translation)、缩放(Scale)、翻转(Flip)、旋转(Rotation)和剪切(Shear)。

        二维的彷射变换是AffineTransformation2D类,彷射变换主要有两种变换:Conformal Transformation(等角变换)和 Affine Tranformation(真彷射变换),对应的接口机器构造函数为:

IAffineTransformation2D3::DefineConformalFromControlPoints和IAffineTransformation2D::DefineFromControlPoints。其中等角变换要求至少两个已知点,因为他的变换函数使用4参数;而真彷射变换要求至少三个已知点,因为他的变换函数使用6参数。

使用arcgis engine实现代码参考如下:

   public static IAffineTransformation2D3GEN TransformMethodDTto2000{ get; set; }
        public static IAffineTransformation2D3GEN GetTransformMethodDTto2000()
        {
            if (TransformMethodDTto2000 != null) return TransformMethodDTto2000;
            //校正控制点,点位一一对应。
            List<IPoint> fromPoints = new List<IPoint>();
            List<IPoint> toPoints = new List<IPoint>();
            //此处fromPoints为本地坐标系控制点
            fromPoints.Add(new PointClass() { X = 30629.419, Y = 27566.627 });
            fromPoints.Add(new PointClass() { X = 30650.761, Y = 27572.848 });
            fromPoints.Add(new PointClass() { X = 39634.757, Y = 21310.338 });
            fromPoints.Add(new PointClass() { X = 39633.747, Y = 21306.358 });
            fromPoints.Add(new PointClass() { X = 27685.06, Y = 21921.377 });
            fromPoints.Add(new PointClass() { X = 27700.645, Y = 21901.178 });
            fromPoints.Add(new PointClass() { X = 22285.505, Y = 10998.906 });
            fromPoints.Add(new PointClass() { X = 22262.987, Y = 10992.98 });
            fromPoints.Add(new PointClass() { X = 15975.327, Y = 17922.094 });
            fromPoints.Add(new PointClass() { X = 15983.915, Y = 17933.157 });
            //此处toPoints为2000坐标系控制点
            toPoints.Add(new PointClass() { X = 441160.807, Y = 4443411.577 });
            toPoints.Add(new PointClass() { X = 441182.195, Y = 4443417.624 });
            toPoints.Add(new PointClass() { X = 450114.331, Y = 4437083.928 });
            toPoints.Add(new PointClass() { X = 450113.289, Y = 4437079.957 });
            toPoints.Add(new PointClass() { X = 438171.511, Y = 4437790.865 });
            toPoints.Add(new PointClass() { X = 438186.931, Y = 4437770.544 });
            toPoints.Add(new PointClass() { X = 432685.145, Y = 4426913.282 });
            toPoints.Add(new PointClass() { X = 432662.583, Y = 4426907.537 });
            toPoints.Add(new PointClass() { X = 426431.277, Y = 4433886.126 });
            toPoints.Add(new PointClass() { X = 426439.954, Y = 4433897.12 });


            IPoint[] fromPointsArray = fromPoints.ToArray();
            IPoint[] toPointsArray = toPoints.ToArray();
            IAffineTransformation2D3GEN transformMethodDTto2000 = GetAffineTransformation(fromPointsArray, toPointsArray);
            TransformMethodDTto2000 = transformMethodDTto2000;
            return transformMethodDTto2000;
        }
        ///从控制点定义仿射变换方程式
        ///源控制点
        ///目标控制点
        ///返回变换定义
        private static IAffineTransformation2D3GEN GetAffineTransformation(IPoint[] pFromPoints, IPoint[] pToPoints)
        {
            //实例化仿射变换对象
            IAffineTransformation2D3GEN tAffineTransformation = new AffineTransformation2DClass();
            //从源控制点定义参数
            tAffineTransformation.DefineFromControlPoints(ref pFromPoints, ref pToPoints);
            return tAffineTransformation;
        }

坐标点仿射变换:

// 本地坐标转为2000坐标

ITransform2D transform2D = pt as ITransform2D;

 transform2D.Transform(esriTransformDirection.esriTransformForward, transformMethodDTto2000 as ITransformation);

// 2000坐标转为本地坐标

ITransform2D transform2D = pt as ITransform2D;

 transform2D.Transform(esriTransformDirection.esriTransformReverse, transformMethodDTto2000 as ITransformation);

在arcmap中可以打开空间校正工具进行操作,操作时需要同时开启编辑工具。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xizhjxust_GIS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值