1

Similar to 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. Whenever I get to the image shown below, I get the HRESULT error 0x80041018 (or -2147217384).

enter image description here

I can pull this image into ArcMap and it renders just fine so I know it isn't corrupt. I tried removing the image from the folder and seeing if it would run successfully but it threw the same error on one about 20 images previous to it (even though it had previously had no problem).

When I looked up the error code here it says:

FDO_E_INVALID_CONNECTION_POINT_GEOMETRY -2147217384 The geometry for a complex junction connection point is invalid.

Not quite sure what to make of this error.

Code:

//how RWSF and IPoint are declared in other methods
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory");
IWorkspaceFactory RWSF = Activator.CreateInstance(factoryType) as IWorkspaceFactory;

IPoint point = new PointClass();
point.SpatialReference = NAD83;
point.PutCoords(longitude, latitude);

//method that uses them
private static void PullImages(IPoint centerpoint, string directoryPath)
{
    IWorkspace ws; IDataset dataset; IRasterLayer rasterLayer;
    ws = RWSF.OpenFromFile(directoryPath, 0);
    IEnumDataset enumDataset = ws.get_Datasets(esriDatasetType.esriDTRasterDataset);
    dataset = enumDataset.Next();

    while (dataset != null)
    {
        IEnvelope rasterEnvelope = (dataset as IGeoDataset).Extent;
        rasterEnvelope.Project(NAD83);
        if ((rasterEnvelope as IRelationalOperator).Contains(centerpoint))
        {
            rasterLayer = new RasterLayerClass();
            rasterLayer.CreateFromDataset(dataset as IRasterDataset);
            MXD.AddLayer(rasterLayer);
        }
        dataset = enumDataset.Next();
    }
}
  • IRelationalOperator isn't implemented by Envelope. You would be better testing if (centerpoint.X > rasterEnvelope.XMin && centerpoint.X < rasterEnvelope.XMax && centerpoint.Y > rasterEnvelope.YMin && centerpoint.Y < rasterEnvelope.YMax) apart from that you code looks fine. – Michael Stimson Feb 17 '17 at 0:54
  • I made those edits but the same error remains – cevondanady Feb 17 '17 at 1:16
  • Does the raster have georeference and spatial reference set? Are you certain that when the function is called the centerpoint is an IPoint object? Does this work with other rasters? If you remove the offending raster from the folder will it run to completion? – Michael Stimson Feb 17 '17 at 1:38
  • If I pull the image into ArcMap it's georeferencing is correct, the method works on many rasters until it gets to that one, if I remove the raster it oddly throws the same error on an image 20 places before the one in question. One that previously had no problem before I removed the other. – cevondanady Feb 17 '17 at 1:42
0

I started migrating all the raster images into another folder in small groups and testing the tool on the new collection each time - it ran successfully for the raster previously in question. I got the error again in the new folder on one of the groups and was able to find the corrupt raster causing the error.

I had incorrectly assumed that the corrupt file was next in line in the order I was seeing it in File Explorer because it was being accessed via IEnumDataset.Next(). But I think the order is different when iterated programmatically. The corrupt file ended up being named "1953_USGS_VBB_2-105.tif". The tool now runs through the collection successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.