<?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 Exception when creating a RasterFunction from JSON file in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/exception-when-creating-a-rasterfunction-from-json/m-p/1201819#M11253</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I basically want to load some raster data (from GeoTIFF file) and then transform it via a Raster Function.&lt;/P&gt;&lt;P&gt;I created the Raster Function Template in ArcGISPro and then exported it in JSON format.&lt;BR /&gt;(Actually exported as XML and then converted to JSON via the Python console using &lt;FONT face="courier new,courier"&gt;arcpy.management.ConvertRasterFunctionTemplate&lt;/FONT&gt;&amp;nbsp;as I found no way to directly export as JSON).&lt;/P&gt;&lt;P&gt;Now, in the code, when I want to create a RasterFunction instance from the JSON file I always get an Exception saying&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Esri.ArcGISRuntime.ArcGISRuntimeException: JSON object key not found.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The documentation of the Runtime SDK (for any language) is vague at best.&lt;/P&gt;&lt;P&gt;When I look at a sample I noticed that the keys in the JSON use snake_case whereas the export from ArcGISPro uses camelCase (or PascalCase).&lt;/P&gt;&lt;P&gt;The sample I'm referring to:&lt;BR /&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/main/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Layers/RasterLayerRasterFunction/RasterLayerRasterFunction.xaml.cs" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/main/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Layers/RasterLayerRasterFunction/RasterLayerRasterFunction.xaml.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I would be grateful for any hint on how to successfully load a Raster Function Template exported from ArcGISPro.&lt;/P&gt;&lt;P&gt;I attached the JSON file with the Raster Function.&lt;/P&gt;&lt;P&gt;I'm using ArcGIS Runtime 100.14.1 and ArcGISPro 3.0&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Christian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2022 11:07:08 GMT</pubDate>
    <dc:creator>cfrob</dc:creator>
    <dc:date>2022-08-11T11:07:08Z</dc:date>
    <item>
      <title>Exception when creating a RasterFunction from JSON file</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/exception-when-creating-a-rasterfunction-from-json/m-p/1201819#M11253</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I basically want to load some raster data (from GeoTIFF file) and then transform it via a Raster Function.&lt;/P&gt;&lt;P&gt;I created the Raster Function Template in ArcGISPro and then exported it in JSON format.&lt;BR /&gt;(Actually exported as XML and then converted to JSON via the Python console using &lt;FONT face="courier new,courier"&gt;arcpy.management.ConvertRasterFunctionTemplate&lt;/FONT&gt;&amp;nbsp;as I found no way to directly export as JSON).&lt;/P&gt;&lt;P&gt;Now, in the code, when I want to create a RasterFunction instance from the JSON file I always get an Exception saying&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Esri.ArcGISRuntime.ArcGISRuntimeException: JSON object key not found.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The documentation of the Runtime SDK (for any language) is vague at best.&lt;/P&gt;&lt;P&gt;When I look at a sample I noticed that the keys in the JSON use snake_case whereas the export from ArcGISPro uses camelCase (or PascalCase).&lt;/P&gt;&lt;P&gt;The sample I'm referring to:&lt;BR /&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/main/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Layers/RasterLayerRasterFunction/RasterLayerRasterFunction.xaml.cs" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/main/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Layers/RasterLayerRasterFunction/RasterLayerRasterFunction.xaml.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I would be grateful for any hint on how to successfully load a Raster Function Template exported from ArcGISPro.&lt;/P&gt;&lt;P&gt;I attached the JSON file with the Raster Function.&lt;/P&gt;&lt;P&gt;I'm using ArcGIS Runtime 100.14.1 and ArcGISPro 3.0&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Christian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 11:07:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/exception-when-creating-a-rasterfunction-from-json/m-p/1201819#M11253</guid>
      <dc:creator>cfrob</dc:creator>
      <dc:date>2022-08-11T11:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Exception when creating a RasterFunction from JSON file</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/exception-when-creating-a-rasterfunction-from-json/m-p/1201842#M11254</link>
      <description>&lt;P&gt;I did some experiments based on the sample mentioned in the original post:&lt;/P&gt;&lt;P&gt;If I take the Raster Function from the sample as a JSON &lt;STRONG&gt;string&lt;/STRONG&gt; and create a RasterFunction instance from that string, it works.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var rftJson = await File.ReadAllTextAsync(@"D:\temp\online_sample.rft.json");
var rasterFunction = RasterFunction.FromJson(rftJson);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I instead try to create the RasterFunction instance directly from the file, it fails.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var rasterFunction = new RasterFunction(@"D:\temp\online_sample.rft.json");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only this time with a different exception:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;System.ArgumentException: Invalid argument: Failed to read 599 bytes from D:\temp\online_sample.rft.json&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I attached the json file I used but with extension .txt as attatching files with .json extension wasn't possible.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Christian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 12:42:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/exception-when-creating-a-rasterfunction-from-json/m-p/1201842#M11254</guid>
      <dc:creator>cfrob</dc:creator>
      <dc:date>2022-08-11T12:42:46Z</dc:date>
    </item>
  </channel>
</rss>

