I'm writing a Desktop Add-In that scans our directories and pulls in georeferenced raster images that contain a point geometry. While it's been working on many image file types so far for some reason I get the HRESULT E_FAIL error when I get to these files via IEnumDataset.Next():
private static void PullImages(IPoint centerpoint, string directoryPath)
{
IWorkspace ws; IDataset dataset; IRasterDataset rasterDataset; IRasterLayer rasterLayer;
ws = RWSF.OpenFromFile(directoryPath, 0);
IEnumDataset enumDataset = ws.get_Datasets(esriDatasetType.esriDTRasterDataset);
dataset = enumDataset.Next();
while (dataset != null)
{
rasterDataset = (ws as IRasterWorkspace).OpenRasterDataset(dataset.BrowseName);
IEnvelope rasterEnvelope = (rasterDataset as IGeoDataset).Extent;
rasterEnvelope.Project(NAD83);
if ((rasterEnvelope as IRelationalOperator).Contains(centerpoint))
{
rasterLayer = new RasterLayerClass();
rasterLayer.CreateFromDataset(rasterDataset);
RemoveHistogramStretchAndMinimize(ref rasterLayer);
MXD.AddLayer(rasterLayer);
}
dataset = enumDataset.Next();
}
}
Answer
The files shown in the screenshot above were corrupt.
No comments:
Post a Comment