AnsweredAssumed Answered

Fastest way to georeference image and add it to globe

Question asked by caca_as on Dec 17, 2015

Hi,

 

I need to create an animation from sequence of .jpg images in Globe. When new image is added, old one should be deleted. Images aren't georeferenced, but I have 4 points indicating where they should be placed.

I tried the following: 

 

    public partial class ArcGISHostControl : UserControl

    {

        Dictionary<string, ILayer> _mainElementRepository;

        string workspace = "C:\\temp\\";

        IWorkspaceFactory wpf;

        IRasterWorkspace rasterworkspace;

 

        public ArcGISHostControl()

        {

            InitializeComponent();

            _mainElementRepository = new Dictionary<string, ILayer>();

            AddBaseLayer(); //adds base maps

            wpf = new RasterWorkspaceFactory();

            raswp = wpf.OpenFromFile(workspace, 0) as IRasterWorkspace;

        }

 

        private string AddNewImage(IPointCollection sourcePoints, IPointCollection targetPoints, string file, string oldID)

        {

            string id = generateID();

            IRasterLayer layer = GeoreferenceImage(file, sourcePoints, targetPoints);

            axGlobeControl.Globe.AddLayerType(layer as ESRI.ArcGIS.Carto.ILayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, true);

            _mainElementRepository.Add(id, layer);

            DeleteObject(oldID);

            return id;

        }

 

        private IRasterLayer GeoreferenceImage(string file, IPointCollection sourcePoints, IPointCollection targetPoints)

        {

            IRasterDataset2 rasterDataset;

            rasterDataset = rasterworkspace.OpenRasterDataset(file) as IRasterDataset2;

            IRasterGeometryProc rasterPropc = new RasterGeometryProcClass();

            IRaster raster = rasterDataset.CreateFullRaster();

 

            rasterPropc.Warp(sourcePoints, targetPoints, esriGeoTransTypeEnum.esriGeoTransProjective, raster);

            rasterPropc.Register(raster);

 

            IRasterLayer layer = new RasterLayerClass();

            layer.CreateFromRaster(raster);

            return layer;

        }

 

        public void DeleteImage(string id)

        {

            ILayer forDeletion;

            if (_mainElementRepository.TryGetValue(id, out forDeletion))

            {

                axGlobeControl.Globe.GlobeDisplay.Scene.DeleteLayer(forDeletion);

                _mainElementRepository.Remove(id);

            }

        }

    }

 

Problem  is that this is very slow, and causes GUI to become nonresponive.

Is there a better way to do this?

Outcomes