<?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 Internal error: The raster layer does not have a spatial reference. in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/internal-error-the-raster-layer-does-not-have-a/m-p/1244693#M11574</link>
    <description>&lt;P&gt;Attempting to load a set of PNG raster files but seeing the following error from the LayerViewStateChanged event.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Internal error: The raster layer does not have a spatial reference.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I don't see any way to set the spatial reference on the RasterLayer as the property only has a getter.&amp;nbsp; Also, I have world files that are in the same directory as the png files.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private async Task LoadMap()
        {
            // create map
            Map myMap = new Map(SpatialReference.Create(3857));
            
            myMap.Basemap = new Basemap(BasemapStyle.ArcGISOceansBase);
            MyMapView.Map = myMap;

            MyMapView.LayerViewStateChanged += MyMapView_LayerViewStateChanged;

            // Get the file name
            string filepath = GetFilesPath();
            var files = Directory.GetFiles(filepath, "*.png");

            foreach (var file in files)
            {
                // Load the raster file
                Raster myRasterFile = new Raster(file);

                // Create the layer
                RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

                // Add the layer to the map
                myMap.OperationalLayers.Add(myRasterLayer);

                try
                {
                    // Wait for the layer to load
                    await myRasterLayer.LoadAsync();

                    // Set the viewpoint
                    await MyMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "Error");
                }
            }
        }
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample - World File Contents&lt;/P&gt;</description>
    <pubDate>Sat, 31 Dec 2022 13:39:24 GMT</pubDate>
    <dc:creator>NathanMoebus</dc:creator>
    <dc:date>2022-12-31T13:39:24Z</dc:date>
    <item>
      <title>Internal error: The raster layer does not have a spatial reference.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/internal-error-the-raster-layer-does-not-have-a/m-p/1244693#M11574</link>
      <description>&lt;P&gt;Attempting to load a set of PNG raster files but seeing the following error from the LayerViewStateChanged event.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Internal error: The raster layer does not have a spatial reference.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I don't see any way to set the spatial reference on the RasterLayer as the property only has a getter.&amp;nbsp; Also, I have world files that are in the same directory as the png files.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private async Task LoadMap()
        {
            // create map
            Map myMap = new Map(SpatialReference.Create(3857));
            
            myMap.Basemap = new Basemap(BasemapStyle.ArcGISOceansBase);
            MyMapView.Map = myMap;

            MyMapView.LayerViewStateChanged += MyMapView_LayerViewStateChanged;

            // Get the file name
            string filepath = GetFilesPath();
            var files = Directory.GetFiles(filepath, "*.png");

            foreach (var file in files)
            {
                // Load the raster file
                Raster myRasterFile = new Raster(file);

                // Create the layer
                RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

                // Add the layer to the map
                myMap.OperationalLayers.Add(myRasterLayer);

                try
                {
                    // Wait for the layer to load
                    await myRasterLayer.LoadAsync();

                    // Set the viewpoint
                    await MyMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "Error");
                }
            }
        }
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample - World File Contents&lt;/P&gt;</description>
      <pubDate>Sat, 31 Dec 2022 13:39:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/internal-error-the-raster-layer-does-not-have-a/m-p/1244693#M11574</guid>
      <dc:creator>NathanMoebus</dc:creator>
      <dc:date>2022-12-31T13:39:24Z</dc:date>
    </item>
  </channel>
</rss>

