阅读:1370回复:0
[求助]Reclass ESRI GRID格式(带属性表)的编程实现问题?高手指教
<P>我用vc+AO在ATL中开发一个dll,想实现类似Arcmap中空间分析里向Reclassify的功能。<BR>现对一个有属性表的栅格数据(ESRI GRID格式)的value字段(long类型)中的值重新赋值。<BR>编译没有问题,但是嵌入到Arcmap中运行时出现错误,不知道是哪里出错了?请高手指教<BR>属性表有4行,value字段值为0,1,2,3,4,通过编程想将其分别改成0,11,22,33,44<BR> IDocumentPtr iDocument;<BR> m_ipApp->get_Document(;iDocument);<BR> IMxDocumentPtr iMxDocument(iDocument);<BR> IMapPtr m_ipMap;<BR> iMxDocument->get_FocusMap(;m_ipMap);</P>
<P> ILayerPtr pLayer;<BR> m_ipMap->get_Layer(0,;pLayer);<BR> IRasterLayerPtr pRLayer(pLayer);<BR> IRasterPtr pRaster;<BR> pRLayer->get_Raster(;pRaster);<BR> IGeoDatasetPtr pGDS;</P> <P> IRasterDescriptorPtr pRD(CLSID_RasterDescriptor);<BR> pRD->Create(pRaster,NULL,_bstr_t("value"));<BR> pGDS=pRD;</P> <P> <BR> IReclassOpPtr pROp(CLSID_RasterReclassOp);<BR> IRasterAnalysisEnvironmentPtr pEnv(pROp);<BR> IWorkspacePtr pWS;<BR> IWorkspaceFactoryPtr pWSF(CLSID_RasterWorkspaceFactory);<BR> pWSF->OpenFromFile(_bstr_t("D:\\GISshiyan\\New Folder"),NULL,;pWS);<BR> pEnv->putref_OutWorkspace(pWS);</P> <P><BR> INumberRemapPtr pNRemap(CLSID_NumberRemap);<BR> pNRemap->MapValue(0,0);<BR> pNRemap->MapValue(1,11);<BR> pNRemap->MapValue(2,22);<BR> pNRemap->MapValue(3,33);<BR> pNRemap->MapValue(4,44);<BR> IRemapPtr pRemap(pNRemap);</P> <P> <BR> IGeoDatasetPtr outGDS;<BR> pROp->ReclassByRemap(pGDS,pRemap,VARIANT_FALSE,;outGDS);<BR> IRasterPtr outR(outGDS);<BR> IRasterLayerPtr outRLayer;<BR> outRLayer->CreateFromRaster(outR);<BR> ILayerPtr outLayer(outRLayer);<BR> m_ipMap->AddLayer(outLayer);</P> <P> return S_OK;</P> <P>另外,我的引用为<BR>#import "D:\Program Files\arcexe83\bin\esriCore.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids exclude("OLE_COLOR","OLE_HANDLE")<BR>#import "D:\Program Files\arcexe83\bin\esriSpatialExt.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids <BR>#import "D:\Program Files\arcexe83\bin\esriSpatialShared.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids exclude("esriGeoAnalysisUnitsEnum","esriRasterNeighborhoodEnum","esriGeoAnalysisFilterEnum","esriGeoAnalysisSemiVariogramEnum","esriGeoAnalysisStatisticsEnum")</P> |
|