<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting raster layer path in ArcGIS Pro using C# in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-raster-layer-path-in-arcgis-pro-using-c/m-p/1121275#M7395</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I use the following code to get raster layer path:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            return QueuedTask.Run&amp;lt;string&amp;gt;(() =&amp;gt;
            {
                try
                {
                    string fullSpec = string.Empty;
                    CIMDataConnection dataConnection = pLayer.GetDataConnection();
                    if (dataConnection is CIMStandardDataConnection)
                    {
                        CIMStandardDataConnection dataSConnection = dataConnection as CIMStandardDataConnection;

                        string sConnection = dataSConnection.WorkspaceConnectionString;

                        var wFactory = dataSConnection.WorkspaceFactory;
                        if (wFactory == WorkspaceFactory.Raster)
                        {
                            string sWorkspaceName = sConnection.Split('=')[1];

                            string sTable = dataSConnection.Dataset;

                            fullSpec = Path.Combine(sWorkspaceName, sTable);
                        }
                    }

                    return fullSpec;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString(), System.Reflection.Assembly.GetExecutingAssembly().FullName);
                    return string.Empty;
                }
            });&lt;/LI-CODE&gt;&lt;P&gt;It works for file based rasters and Esri GRIDs. I don't check how it works with sde stored rasters&lt;/P&gt;</description>
    <pubDate>Tue, 30 Nov 2021 15:55:18 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2021-11-30T15:55:18Z</dc:date>
    <item>
      <title>Getting raster layer path in ArcGIS Pro using C#</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-raster-layer-path-in-arcgis-pro-using-c/m-p/1121166#M7393</link>
      <description>&lt;P&gt;I am creating an ArcGIS Pro Extension. I need to know the layer's path. To get the layer path, code developed so far:&lt;/P&gt;&lt;PRE&gt;var pointLayer = MapView.Active.Map.Layers.OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault();
var rasterLayer = MapView.Active.Map.Layers.OfType&amp;lt;RasterLayer&amp;gt;().FirstOrDefault();
var pointLayerPath = await QueuedTask.Run(() =&amp;gt; pointLayer.GetPath());
var rasterLayerPath = await QueuedTask.Run(() =&amp;gt; rasterLayer.GetPath());&lt;/PRE&gt;&lt;P&gt;pointLayerPath&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is assigned the correct path but&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;rasterLayerPath&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is assigned a null value.&lt;BR /&gt;The result is the same for this code also.&lt;BR /&gt;&lt;SPAN&gt;MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;RasterLayer&amp;gt;().FirstOrDefault();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can I get the RasterLayer path?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 08:42:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-raster-layer-path-in-arcgis-pro-using-c/m-p/1121166#M7393</guid>
      <dc:creator>osmansheikh</dc:creator>
      <dc:date>2021-11-30T08:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting raster layer path in ArcGIS Pro using C#</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-raster-layer-path-in-arcgis-pro-using-c/m-p/1121275#M7395</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I use the following code to get raster layer path:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            return QueuedTask.Run&amp;lt;string&amp;gt;(() =&amp;gt;
            {
                try
                {
                    string fullSpec = string.Empty;
                    CIMDataConnection dataConnection = pLayer.GetDataConnection();
                    if (dataConnection is CIMStandardDataConnection)
                    {
                        CIMStandardDataConnection dataSConnection = dataConnection as CIMStandardDataConnection;

                        string sConnection = dataSConnection.WorkspaceConnectionString;

                        var wFactory = dataSConnection.WorkspaceFactory;
                        if (wFactory == WorkspaceFactory.Raster)
                        {
                            string sWorkspaceName = sConnection.Split('=')[1];

                            string sTable = dataSConnection.Dataset;

                            fullSpec = Path.Combine(sWorkspaceName, sTable);
                        }
                    }

                    return fullSpec;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString(), System.Reflection.Assembly.GetExecutingAssembly().FullName);
                    return string.Empty;
                }
            });&lt;/LI-CODE&gt;&lt;P&gt;It works for file based rasters and Esri GRIDs. I don't check how it works with sde stored rasters&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 15:55:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-raster-layer-path-in-arcgis-pro-using-c/m-p/1121275#M7395</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-11-30T15:55:18Z</dc:date>
    </item>
  </channel>
</rss>

