<?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: How to change data source of Stereo Map in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328561#M10388</link>
    <description>&lt;P&gt;Hi Barbara,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you have forgotten to save the updated CIM definition back to the map.&amp;nbsp; &amp;nbsp;Remember that a GetDefinition call also needs a SetDefinition call after any updates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try adding a&amp;nbsp;&amp;nbsp;steroMap.SetDefinition call with your updated cimMap before you redraw.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Sep 2023 03:56:23 GMT</pubDate>
    <dc:creator>NarelleChedzey</dc:creator>
    <dc:date>2023-09-14T03:56:23Z</dc:date>
    <item>
      <title>How to change data source of Stereo Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328189#M10382</link>
      <description>&lt;P&gt;I'm using the following code to change the data source of the stereo map, but it doesn't work:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await QueuedTask.Run(async () =&amp;gt;
{
    Map stereoMap = await ProjectUtils.GetStereoMapAsync();
    CIMMap cimMap = stereoMap.GetDefinition();
    var stereoProps = cimMap.StereoProperties;

    WorkspaceFactory workspaceFactory = WorkspaceFactory.FileGDB;
    var fileGdbConnPath = new FileGeodatabaseConnectionPath(new Uri(@"D:\Data\StartProject.gdb", UriKind.Absolute));
    var workspaceConnectionString = new Geodatabase(fileGdbConnPath).GetConnectionString();

    CIMStandardDataConnection mosaicDataConnection = new  CIMStandardDataConnection()
    {
        WorkspaceConnectionString = workspaceConnectionString,
        WorkspaceFactory = workspaceFactory,
        Dataset = "MyMosaic",
        DatasetType = esriDatasetType.esriDTMosaicDataset
    };
    stereoProps.StereoModelCollection = mosaicDataConnection;
    cimMap.StereoProperties = stereoProps;

    MapView.Active.Redraw(true);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any help is appreciated, thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 10:53:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328189#M10382</guid>
      <dc:creator>BarbaraSchneider2</dc:creator>
      <dc:date>2023-09-13T10:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to change data source of Stereo Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328561#M10388</link>
      <description>&lt;P&gt;Hi Barbara,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you have forgotten to save the updated CIM definition back to the map.&amp;nbsp; &amp;nbsp;Remember that a GetDefinition call also needs a SetDefinition call after any updates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try adding a&amp;nbsp;&amp;nbsp;steroMap.SetDefinition call with your updated cimMap before you redraw.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 03:56:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328561#M10388</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-09-14T03:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to change data source of Stereo Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328683#M10391</link>
      <description>&lt;P&gt;Hi Narelle,&lt;/P&gt;&lt;P&gt;thank you for your reply! It works now. However, I can only set the data source if there already is a data source set. If I manually clear the data source of the Stereo Map and then add the data source again programmatically, nothing happens. Is this a bug?&lt;/P&gt;&lt;P&gt;Thank you,&lt;BR /&gt;Barbara&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 13:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328683#M10391</guid>
      <dc:creator>BarbaraSchneider2</dc:creator>
      <dc:date>2023-09-14T13:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to change data source of Stereo Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328980#M10399</link>
      <description>&lt;P&gt;Barbara,&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the data source has been cleared, then you probably need to also set other properties on the CIMMapStereoProperties instance.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try something similar to the following&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{
  Map stereoMap = MapView.Active.Map;

  await QueuedTask.Run(async () =&amp;gt;
  {
    CIMMap cimMap = stereoMap.GetDefinition();
    var stereoProps = cimMap.StereoProperties;

    string path = @"D:\Data\StartProject.gdb";
    var fileGdbConnPath = new FileGeodatabaseConnectionPath(new Uri(path, UriKind.Absolute));

    using (var gdb = new Geodatabase(fileGdbConnPath))
    {
      ArcGIS.Core.Data.Raster.MosaicDataset mDataset = gdb.OpenDataset&amp;lt;ArcGIS.Core.Data.Raster.MosaicDataset&amp;gt;("MyMoaid");
      var mosaicDataConnection = mDataset.GetDataConnection();

      var (leftImageID, rightImageID) = GetStereoImages(mDataset);
          
      stereoProps.SourceType = StereoSourceType.StereoModelCollection;
      stereoProps.StereoModelCollection = mosaicDataConnection;
      stereoProps.LeftImageID = leftImageID;
      stereoProps.RightImageID = rightImageID;

      cimMap.StereoProperties = stereoProps;

      stereoMap.SetDefinition(cimMap);
    }

  //        MapView.Active.Redraw(true);
  });
}

// Find the left and right image IDs from the mosaicDataset
// This is achieved by querying the stereo table and retrieving
// the ImageID1 and ImageID2 fields. 
(long image1ID, long image2ID) GetStereoImages(ArcGIS.Core.Data.Raster.MosaicDataset mDataset)
{
  var stereoTable = mDataset?.GetStereoTable();
  var stereoTableDef = stereoTable?.GetDefinition();
  if (stereoTableDef == null)
    return (-1, -1);

  var image1Fld = stereoTableDef.FindField("ImageID1");
  var image2Fld = stereoTableDef.FindField("ImageID2");
  if ((image1Fld == -1) || (image2Fld == -1))
    return (-1, -1);

  long image1 = -1;
  long image2 = -1;
  using (var cursor = stereoTable.Search(null))
  {
    if (cursor.MoveNext())
    {
      using (var row = cursor.Current)
      {
        var image = row[image1Fld];
        if (image != null)
          System.Int64.TryParse(image.ToString(), out image1);
        image = row[image2Fld].ToString();
        if (image != null)
          System.Int64.TryParse(image.ToString(), out image2);
      }
    }
  }

  return (image1, image2);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may also need to set the LeftImageColorizer and RightImageColorizer properties, but I am not sure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this still doesn't work for you.&amp;nbsp; It worked for my test scenario, but I am not a raster expert.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2023 05:29:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1328980#M10399</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2023-09-15T05:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to change data source of Stereo Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1332839#M10481</link>
      <description>&lt;P&gt;Hello Narelle,&lt;/P&gt;&lt;P&gt;this works! I don't need to set the LeftImageColorizer and RightImageColorizer. Thank you very much.&lt;/P&gt;&lt;P&gt;Barbara&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 11:06:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-change-data-source-of-stereo-map/m-p/1332839#M10481</guid>
      <dc:creator>BarbaraSchneider2</dc:creator>
      <dc:date>2023-09-27T11:06:22Z</dc:date>
    </item>
  </channel>
</rss>

