Friday 25 January 2019

raster - HRESULT E_FAIL Error -2147467259 when using IEnumDataset.Next()


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


enter image description here


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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...