使tif图像变成geotif,加gcp信息时没成功

28 views
Skip to first unread message

迪西

unread,
Apr 1, 2009, 5:50:34 AM4/1/09
to gdal+python+GIS+geosings论坛
怎么给一个tif加GCP信息?
通过gdal_translate -gcp 可以实现
这是源代码(gdal_translate.cpp)
else if( EQUAL(argv[i],"-gcp") && i < argc - 4 )
{
/* -gcp pixel line easting northing [elev] */

nGCPCount++;
pasGCPs = (GDAL_GCP *)
CPLRealloc( pasGCPs, sizeof(GDAL_GCP) * nGCPCount );
GDALInitGCPs( 1, pasGCPs + nGCPCount - 1 );

pasGCPs[nGCPCount-1].dfGCPPixel = atof(argv[++i]);
pasGCPs[nGCPCount-1].dfGCPLine = atof(argv[++i]);
pasGCPs[nGCPCount-1].dfGCPX = atof(argv[++i]);
pasGCPs[nGCPCount-1].dfGCPY = atof(argv[++i]);
if( argv[i+1] != NULL
&& (atof(argv[i+1]) != 0.0 || argv[i+1][0] == '0') )
pasGCPs[nGCPCount-1].dfGCPZ = atof(argv[++i]);

/* should set id and info? */
}


我在自己程序里这样写:
GDAL_GCP * pasGCPList = NULL;
int mGcpCount = 4;
//gcplist
pasGCPList = (GDAL_GCP *)CPLRealloc( pasGCPList, sizeof
(GDAL_GCP) * mGcpCount );

pasGCPList[0].dfGCPPixel = 0;
pasGCPList[0].dfGCPLine = 0;
pasGCPList[0].dfGCPX = -863909;
pasGCPList[0].dfGCPY = -993283;
pasGCPList[0].dfGCPZ = 0;
pasGCPList[0].pszId = "1";
pasGCPList[0].pszInfo = "info 1";

pasGCPList[1].dfGCPPixel = 0;
pasGCPList[1].dfGCPLine = 201;
pasGCPList[1].dfGCPX = -863909;
pasGCPList[1].dfGCPY = -1024899;
pasGCPList[1].dfGCPZ = 0;
pasGCPList[1].pszId = "2";
pasGCPList[1].pszInfo = "info 2";

pasGCPList[2].dfGCPPixel = 201;
pasGCPList[2].dfGCPLine = 201;
pasGCPList[2].dfGCPX = -809988;
pasGCPList[2].dfGCPY = -1024899;
pasGCPList[2].dfGCPZ = 0;
pasGCPList[2].pszId = "3";
pasGCPList[2].pszInfo = "info 3";

pasGCPList[3].dfGCPPixel = 201;
pasGCPList[3].dfGCPLine = 0;
pasGCPList[3].dfGCPX = -809988;
pasGCPList[3].dfGCPY = 0;
pasGCPList[3].dfGCPZ = 0;
pasGCPList[3].pszId = "3";
pasGCPList[3].pszInfo = "info 3";

char * m_GcpProjection = "WGS_84";
poVDS->SetGCPs(mGcpCount,pasGCPList,m_GcpProjection);

输出图像后,发现tif仍然没有gcp信息
不知道哪里出了问题

linux23...@gmail.com

unread,
Apr 1, 2009, 10:54:23 PM4/1/09
to gdal+python+GIS+geosings论坛
看来是时候研究下GCPs了......

为什么突然一下子大家都开始研究GCPs了?

迪西

unread,
Apr 2, 2009, 12:35:32 AM4/2/09
to gdal+python+GIS+geosings论坛


On 4月2日, 上午10时54分, "linux23maill...@gmail.com"
> > 不知道哪里出了问题- 隐藏被引用文字 -
>
> - 显示引用的文字 -
因为GCP纠正是目前最好的几何纠正方式,精度最高。希望lilin好好研究写,给大家一些指点

迪西

unread,
Apr 2, 2009, 5:35:25 AM4/2/09
to gdal+python+GIS+geosings论坛

> 因为GCP纠正是目前最好的几何纠正方式,精度最高。希望lilin好好研究写,给大家一些指点- 隐藏被引用文字 -
>
> - 显示引用的文字 -
希望有兴趣的朋友多讨论一下,怎么里设置gcp及利用gcp

Reply all
Reply to author
Forward
0 new messages