阅读:1529回复:0
[求助]IZonal的ZonalStatisticsAsTable
<P> IFeatureClassPtr ipFeatureClass;<BR> IRasterPtr ipRaster;<BR> ipFeaLayer ->get_FeatureClass(;ipFeatureClass);<BR> ipRasLayer ->get_Raster(;ipRaster);<BR> IGeoDatasetPtr ipGeoZone, ipGeoRaster;<BR> <BR> IFeatureClassDescriptorPtr ipFeaDes;<BR> ipFeaDes.CreateInstance(CLSID_FeatureClassDescriptor);<BR> ipFeaDes->Create(ipFeatureClass, 0, CComBSTR("NewFID"));<BR> ipFeaDes.QueryInterface(__uuidof(IGeoDataset),(void **);ipGeoZone);<BR> ipRaster.QueryInterface(__uuidof(IGeoDataset),(void **);ipGeoRaster);</P>
<P> ////////////////////////////zonal//////////////////////////////////////////////</P> <P> ITablePtr ipTable;<BR> IZonalOpPtr ipZonal;<BR> ipZonal.CreateInstance(CLSID_RasterZonalOp);</P> <P> IRasterAnalysisEnvironmentPtr ipEnv;<BR> ipZonal.QueryInterface(__uuidof(IRasterAnalysisEnvironmentPtr), (void **);ipEnv);<BR> IWorkspacePtr ipWS;<BR> IWorkspaceFactoryPtr ipWSF;<BR> ipWSF.CreateInstance(CLSID_RasterWorkspaceFactory);<BR> ipWSF->OpenFromFile(CComBSTR("C:\\Temp"), 0, ;ipWS);<BR> ipEnv->putref_OutWorkspace(ipWS);<BR> <BR> ipZonal ->ZonalStatisticsAsTable(ipGeoZone, ipGeoRaster, TRUE, ;ipTable);<BR> if(ipTable == 0)return S_FALSE;<BR> long lCount;<BR> ipTable ->RowCount(NULL,;lCount);</P> <P>运行后,lcount值为0,但用例子里的VBA算同样的数据,则能得出正确结果</P> <P>请大牛指点,谢谢</P> |
|