Arcgis的坐标参考文件一般是以.prj为后缀
即
std::string strPrj1 = "ESRI::" + strProjFileName1;
OGRSpatialReference oSourceSRS;
oSourceSRS.SetFromUserInput(strPrj1.c_str());
std::string strPrj2 = "ESRI::" + strProjFileName2;
OGRSpatialReference oTargetSRS;
oTargetSRS.SetFromUserInput(strPrj2.c_str());
//坐标系转换
double srcX = 120.235842;
double srcY = 30.222458;
double x = srcX;
double y = srcY;
OGRCoordinateTransformation *poCT = OGRCreateCoordinateTransformation(&oSourceSRS,
&oTargetSRS);
if (poCT == NULL || !poCT->Transform(1, &x, &y))
printf("Transformation failed.\n");
else
{
printf("(%f,%f) ->(%f,%f)\n", srcX, srcY, x, y);
}
因为如果解析字符串,容易出错
这篇博客介绍了ArcGIS中坐标参考文件.prj的使用,通过示例代码展示了如何进行坐标转换,包括设置OGRSpatialReference对象以及使用OGRCoordinateTransformation进行坐标平移。博客强调了正确处理.prj文件以避免解析错误的重要性。
5578

被折叠的 条评论
为什么被折叠?



