ArcEngine:The XY domain on the spatial reference is not set or invalid错误

在创建数据集的时候,提示The XY domain on the spatial reference is not set or invalid错误。

原因:未设置空间参考(ISpatialReference)的域范围(Domain)。

解决方法:通过以下代码进行设置Domain即可:pSpatialReference.SetDomain(xmin, xmax, ymin, ymax);

代码示例:

ISpatialReferenceFactory pSpatialReferenceEnvironment = new SpatialReferenceEnvironment();
pComReleaser.ManageLifetime(pSpatialReferenceEnvironment);
ISpatialReference pSpatialReference = pSpatialReferenceEnvironment.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_World_Mercator);
pComReleaser.ManageLifetime(pSpatialReference);
pSpatialReferenceEnvironment.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
pSpatialReference.SetDomain(-60000000, 60000000, -60000000, 60000000);
//创建要素数据集
IFeatureDataset pFeatureDataset = PGeoDbGeneral.CreateFeatureDataset(pWorkspace, txtFtDataset.Text, pSpatialReference);
pComReleaser.ManageLifetime(pFeatureDataset);

原文地址:https://www.cnblogs.com/Jingkunliu/p/4497616.html