petra.zieger

How to set SnapRaster in ArcObjects (Java) to improve zonal statistics?

Discussion created by petra.zieger on Sep 13, 2012
Hello,
I manged to set the analysis environment to a special rasterlayer with RasterAnalysis...
But where can I find a statement like env.setSnapRaster(RasterLayer)?

   // setting the environmental settings for raster analysis
   RasterLayer rl =  (RasterLayer) Util.getILayerFromToc(mxDoc, nameDomLayer);
   IEnvelope processingExtent = rl.getExtent();
   RasterAnalysis env = new RasterAnalysis();
   env.setExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, processingExtent, null);
   env.setCellSize(esriRasterEnvSettingEnum.esriRasterEnvMinOf, domGeoDataset);
   env.setOutWorkspaceByRef(workspaceRaster);
   env.setAsNewDefaultEnvironment();

Here the background to my question: I want to set the environment before making a zonal Statistic:

   IZonalOp zo = new RasterZonalOp();
   ITable zonStatTable = zo.zonalStatisticsAsTable(new IGeoDatasetProxy(myfeatClass), myGeoDataset, true);

I would like to calculate the zonalStatisticsAsTable within the extent of the boundarys of the selected features. In runtime the amount of selected features is set by the user. I can set the env.setExtent to this selection, but the result of the zonal statistics changes than with the SelectionSet, because ArcGis seems to make a raster from the features and the bounding box of the features defines the raster-starting-point. This raster (is obviously calculated deep inside of the zonalStatics-Routine of Arcobjects) and does not snap to the Raster in MyGeoDataset (RasterLayer of zonal statistics). I want to have always the same result, the SelectionSet of Features should not change the result. Therefore it's necessary to set the snapRaster to the rasterLayer, which is all the time the same.

Has anybody an idea?

Greetings from
Petra

Outcomes