<?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 Problem with Raster.PixelToMap in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/problem-with-raster-pixeltomap/m-p/1129919#M7559</link>
    <description>&lt;P&gt;I wrote a bit of code to show me the extent (footprint) of a raster with a Polyline. It should be fairly simple by getting the map coordinates of four corner pixels of the raster. Yes, I'm aware that those should give me the coordinates of the center of those pixels, but that's fine. The code works fine for Rasters with orthogonal georeferencing, but has problems if the georeferencing rotates and stretches the image.&lt;/P&gt;&lt;P&gt;See screenshot below for the results I'm getting&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;       await QueuedTask.Run(() =&amp;gt;
        {
          pOutLay = (FeatureLayer)LayerFactory.Instance.CreateLayer(new Uri(url), MapView.Active.Map);
          pSpatRef = SpatialReferenceBuilder.CreateSpatialReference(32655); //UTM55N
          EditOperation createFeatEditOp = new EditOperation();
          createFeatEditOp.Name = "CreateImageEdges";
          createFeatEditOp.SelectModifiedFeatures = false;
          createFeatEditOp.SelectNewFeatures = false;

          foreach (Item itm in items)
          {
            lstPnt = new List&amp;lt;MapPoint&amp;gt;();
            string path = itm.Path.Substring(0, itm.Path.LastIndexOf(@"\"));
            string strFile = itm.Path.Substring(itm.Path.LastIndexOf(@"\") + 1);
            FileSystemConnectionPath connectionPath = new FileSystemConnectionPath(new System.Uri(path), FileSystemDatastoreType.Raster);
            FileSystemDatastore dataStore = new FileSystemDatastore(connectionPath);
            RasterDataset fileRasterDataset = dataStore.OpenDataset&amp;lt;RasterDataset&amp;gt;(strFile);
            Raster pRas = fileRasterDataset.CreateDefaultRaster();
            pTup = pRas.PixelToMap(0, 0);
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(0, pRas.GetWidth());
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(pRas.GetHeight(), pRas.GetWidth());
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(pRas.GetHeight(), 0);
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(0, 0);
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));


            pPline = PolylineBuilder.CreatePolyline(lstPnt, pSpatRef);
            dctAtts = new Dictionary&amp;lt;string, object&amp;gt;();
            dctAtts.Add("SHAPE", pPline);
            dctAtts.Add("Image", strFile);
            dctAtts.Add("Width", pRas.GetWidth());
            dctAtts.Add("Height", pRas.GetHeight());
            createFeatEditOp.Create(pOutLay, dctAtts);
          }
          createFeatEditOp.Execute();

        });
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message);
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;The size of this image is 8272x6200 and you can see in the table that I'm not getting the correct height from the Raster object either.&lt;/P&gt;&lt;P&gt;Any idea what's going on here?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ScreenCap.jpg" style="width: 505px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30601i8B9571E9C2F358D7/image-size/large?v=v2&amp;amp;px=999" role="button" title="ScreenCap.jpg" alt="ScreenCap.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ScreenCap2.jpg" style="width: 391px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30602iE67D899CBC3ACA90/image-size/large?v=v2&amp;amp;px=999" role="button" title="ScreenCap2.jpg" alt="ScreenCap2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jan 2022 01:31:53 GMT</pubDate>
    <dc:creator>BerndtNording</dc:creator>
    <dc:date>2022-01-01T01:31:53Z</dc:date>
    <item>
      <title>Problem with Raster.PixelToMap</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/problem-with-raster-pixeltomap/m-p/1129919#M7559</link>
      <description>&lt;P&gt;I wrote a bit of code to show me the extent (footprint) of a raster with a Polyline. It should be fairly simple by getting the map coordinates of four corner pixels of the raster. Yes, I'm aware that those should give me the coordinates of the center of those pixels, but that's fine. The code works fine for Rasters with orthogonal georeferencing, but has problems if the georeferencing rotates and stretches the image.&lt;/P&gt;&lt;P&gt;See screenshot below for the results I'm getting&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;       await QueuedTask.Run(() =&amp;gt;
        {
          pOutLay = (FeatureLayer)LayerFactory.Instance.CreateLayer(new Uri(url), MapView.Active.Map);
          pSpatRef = SpatialReferenceBuilder.CreateSpatialReference(32655); //UTM55N
          EditOperation createFeatEditOp = new EditOperation();
          createFeatEditOp.Name = "CreateImageEdges";
          createFeatEditOp.SelectModifiedFeatures = false;
          createFeatEditOp.SelectNewFeatures = false;

          foreach (Item itm in items)
          {
            lstPnt = new List&amp;lt;MapPoint&amp;gt;();
            string path = itm.Path.Substring(0, itm.Path.LastIndexOf(@"\"));
            string strFile = itm.Path.Substring(itm.Path.LastIndexOf(@"\") + 1);
            FileSystemConnectionPath connectionPath = new FileSystemConnectionPath(new System.Uri(path), FileSystemDatastoreType.Raster);
            FileSystemDatastore dataStore = new FileSystemDatastore(connectionPath);
            RasterDataset fileRasterDataset = dataStore.OpenDataset&amp;lt;RasterDataset&amp;gt;(strFile);
            Raster pRas = fileRasterDataset.CreateDefaultRaster();
            pTup = pRas.PixelToMap(0, 0);
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(0, pRas.GetWidth());
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(pRas.GetHeight(), pRas.GetWidth());
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(pRas.GetHeight(), 0);
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
            pTup = pRas.PixelToMap(0, 0);
            lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));


            pPline = PolylineBuilder.CreatePolyline(lstPnt, pSpatRef);
            dctAtts = new Dictionary&amp;lt;string, object&amp;gt;();
            dctAtts.Add("SHAPE", pPline);
            dctAtts.Add("Image", strFile);
            dctAtts.Add("Width", pRas.GetWidth());
            dctAtts.Add("Height", pRas.GetHeight());
            createFeatEditOp.Create(pOutLay, dctAtts);
          }
          createFeatEditOp.Execute();

        });
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message);
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;The size of this image is 8272x6200 and you can see in the table that I'm not getting the correct height from the Raster object either.&lt;/P&gt;&lt;P&gt;Any idea what's going on here?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ScreenCap.jpg" style="width: 505px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30601i8B9571E9C2F358D7/image-size/large?v=v2&amp;amp;px=999" role="button" title="ScreenCap.jpg" alt="ScreenCap.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ScreenCap2.jpg" style="width: 391px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30602iE67D899CBC3ACA90/image-size/large?v=v2&amp;amp;px=999" role="button" title="ScreenCap2.jpg" alt="ScreenCap2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jan 2022 01:31:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/problem-with-raster-pixeltomap/m-p/1129919#M7559</guid>
      <dc:creator>BerndtNording</dc:creator>
      <dc:date>2022-01-01T01:31:53Z</dc:date>
    </item>
  </channel>
</rss>

