Select to view content in your preferred language

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

3214
0
11-15-2015 08:56 AM
ryantan
Deactivated User

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();

rasterLayer.createFromRaster(raster);

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.

Thanks!

Ryan

0 Kudos
0 Replies