现在的位置: 首页 > 综合 > 正文

gdal GetGeoTransform解释 GetProjectionRef

2016年11月17日 ⁄ 综合 ⁄ 共 1757字 ⁄ 字号 评论关闭

  GDALDataset中有函数GetGeoTransform(),函数声明为: CPLErr GDALDataset::GetGeoTransform  ( double *  padfTransform  )。

        GDAL官网对该函数说明为:

        Fetch the affine transformation coefficients.

        Fetches the coefficients for transforming between pixel/line (P,L) raster space, and projection coordinates (Xp,Yp) space。

                             Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2];

                             Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];

      参数padfTransform是一个指向六个元素的double类型指针,各个元素意义如下:

      In a north up image, padfTransform[1] is the pixel width, and padfTransform[5] is the pixel height. The upper left corner of the upper left pixel is at position (padfTransform[0],padfTransform[3]).

      The default transform is (0,1,0,0,0,1) and should be returned even when a CE_Failure error is returned, such as for formats that don't support transformation to projection coordinates.

 

Parameters:
      padfTransform  an existing six double buffer into which the transformation will be placed.

Returns:
      CE_None on success, or CE_Failure if no transform can be fetched.

 

 //如果图像不含地理坐标信息,默认返回值是:(0,1,0,0,0,1)
 //In a north up image,
 //左上角点坐标(padfGeoTransform[0],padfGeoTransform[3]);
 //padfGeoTransform[1]是像元宽度(影像在宽度上的分辨率);
 /p/adfGeoTransform[5]是像元高度(影像在高度上的分辨率);
 //如果影像是指北的,padfGeoTransform[2]和padfGeoTransform[4]这两个参数的值为0。

后面继续补充有关于这个坐标系统的定义

GDAL数据集有两种模式描述栅格位置(用点/线坐标系)以及地理参考坐标系之间的关系:首要的也是最普遍的是使用仿射转换,另一种则是GCPs(多控制点定位方式)

  • 仿射变换由6个参数构成,它们由GDALDataset::!GetGeoTransform()返回它们把点/线坐标系(我想这里的(点/线)意思是栅格的(行/列)位置)用下面的关系转换到地理参考空间。

Toggle line numbersToggle
line numbers

   1 Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2)
   2 Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5)

假设指北针向上的影像,GT2和GT4参数是0,而GT1是象元宽,GT5是象元高,(GT0,GT3)点位置是影像的左上角。

注意,上面所说的点/线坐标系是从左上角(0,0)点到右下角,也就是坐标轴从左到右增长,从上到下增长的坐标系。点/线位置中心是(0.5,0.5)扩充:


另外一个函数  GetProjectionRef()通过这个可以获得仿射坐标系统的描述,获得的是一个指向内部投影参考字符串的指针

 

抱歉!评论已关闭.