AnsweredAssumed Answered

How to Cast a IGeoDataset into IRaster in Java SDK(arcobjects)

Question asked by ryan4fun on Nov 15, 2015

I'm using arcgis 10.2 Java SDK (I'm using ArcObjects NOT the Runtime SDK) try to do a IDW interpolation and I'm following the instruction from

ArcObjects Help for Java developers

but I got a ClassCastException when I deal with the returned object from IDW operation.

my code is like this:


IInterpolationOp interpolationOP = new RasterInterpolationOp();

IRasterAnalysisEnvironment interpolationEnv = (IRasterAnalysisEnvironment)interpolationOP;

interpolationEnv .setCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue,  cellsize);

IRasterRadius radius = new RasterRadius();

radius .setFixed(10, new Integer(0));

IGeoDataset outGeo = interpolationOP.iDW(inputData, power, radius,  null);

IRaster raster = (IRaster)outGeo;

RasterLayer rasterLayer = new RasterLayer();


mapBean.addLayer(rasterLayer, 0);


the emphasized line is where the exception occurred. from the help document, it doesn't mention how to convert the geoDataset to a Raster so in my understanding it's a normal Java cast, but I'm wrong. 

I also tried the deprecated method :

IRaster raster = new Raster(outGeo);

doesn't work either.


I googled, there are a lot of c# sample code, just using a geoDataset as IRaster will do the trick,  but i couldn't find a java sample.

Any idea will be appreciated.