How do I check for the existence of a raster in the project geodatabase?

66
2
Jump to solution
10-01-2019 11:50 AM
Highlighted
New Contributor III

I need to check for the existence of a raster in the project database.  Does anyone have the C# code for ArcGIS Pro?

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Regular Contributor

Hi Sam,

Try code below. FilePath is your raster path in geodatabase. Instead of creating layer you can do what you want

        private Task AddToMap()
        {
            return QueuedTask.Run(() =>
            {
                try
                {
                    // first we create an 'Item' using itemfactory
                    Item currentItem = ItemFactory.Instance.Create(FilePath);

                    // Finally add the feature service to the map
                    // if we have an item that can be turned into a layer
                    // add it to the map
                    if (LayerFactory.Instance.CanCreateLayerFrom(currentItem))
                        LayerFactory.Instance.CreateLayer(currentItem, MapView.Active.Map);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error while adding vector tile to map");
                }
            });
        }

View solution in original post

Reply
0 Kudos
2 Replies
Highlighted
Regular Contributor

Hi Sam,

Try code below. FilePath is your raster path in geodatabase. Instead of creating layer you can do what you want

        private Task AddToMap()
        {
            return QueuedTask.Run(() =>
            {
                try
                {
                    // first we create an 'Item' using itemfactory
                    Item currentItem = ItemFactory.Instance.Create(FilePath);

                    // Finally add the feature service to the map
                    // if we have an item that can be turned into a layer
                    // add it to the map
                    if (LayerFactory.Instance.CanCreateLayerFrom(currentItem))
                        LayerFactory.Instance.CreateLayer(currentItem, MapView.Active.Map);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error while adding vector tile to map");
                }
            });
        }

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor III

Perfect!!!!   thanks Gintautas....  much appreciated.

Reply
0 Kudos