迪西
unread,Apr 1, 2009, 5:50:34 AM4/1/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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信息
不知道哪里出了问题