Repository: Esri/arcgis-maps-sdk-swift-samples
Pull request #599: [New] Apply function to raster from file
Author: login: des12437
Created: 2025-05-07T22:45:28Z | Merged: 2025-05-16T18:58:21Z

## Description

This PR implements `Apply function to raster from file` in `Visualization` category.
URL to README: [URL](https://github.com/Esri/arcgis-maps-sdk-swift-samples/tree/destiny/Apply-function-to-raster-from-file/Shared/Samples/Apply%20function%20to%20raster%20from%20file#readme)

## Linked Issue(s)

- `swift/issues/6847`

## How To Test
Open the sample.

## Screenshots

![apply-function-to-raster-from-file](https://github.com/user-attachments/assets/5468191a-b5f3-4477-9408-e0c1f9117647)



Diff:
diff --git a/Samples.xcodeproj/project.pbxproj b/Samples.xcodeproj/project.pbxproj
index 1d51ebf6c..02200c115 100644
--- a/Samples.xcodeproj/project.pbxproj
+++ b/Samples.xcodeproj/project.pbxproj
@@ -141,6 +141,7 @@
 		1C26ED202A8BEC63009B7721 /* FilterFeaturesInSceneView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1C26ED152A859525009B7721 /* FilterFeaturesInSceneView.swift */; };
 		1C293D012DCA7C99000B0822 /* ApplyBlendRendererToHillshadeView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1C3891602DC02F1100ADFDDC /* ApplyBlendRendererToHillshadeView.swift */; };
 		1C293D032DCA7C99000B0822 /* ApplyBlendRendererToHillshadeView.SettingsView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1C3892302DC59E5D00ADFDDC /* ApplyBlendRendererToHillshadeView.SettingsView.swift */; };
+		1C293D4D2DCD91BF000B0822 /* color.json in Resources */ = {isa = PBXBuildFile; fileRef = 1C293D4B2DCD91BF000B0822 /* color.json */; settings = {ASSET_TAGS = (ApplyFunctionToRasterFromFile, ); }; };
 		1C29C9592DBAE50D0074028F /* AddWMTSLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C29C9532DBAE50D0074028F /* AddWMTSLayerView.swift */; };
 		1C29C95A2DBAE5770074028F /* AddWMTSLayerView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1C29C9532DBAE50D0074028F /* AddWMTSLayerView.swift */; };
 		1C38915D2DBC36C800ADFDDC /* AddWFSLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C38915C2DBC36C700ADFDDC /* AddWFSLayerView.swift */; };
@@ -171,7 +172,9 @@
 		1CAB8D502A3CEB43002AA649 /* RunValveIsolationTraceView.Model.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D442A3CEAB0002AA649 /* RunValveIsolationTraceView.Model.swift */; };
 		1CAB8D512A3CEB43002AA649 /* RunValveIsolationTraceView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D472A3CEAB0002AA649 /* RunValveIsolationTraceView.swift */; };
 		1CAF831F2A20305F000E1E60 /* ShowUtilityAssociationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF831B2A20305F000E1E60 /* ShowUtilityAssociationsView.swift */; };
-		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; settings = {ASSET_TAGS = (ApplyBlendRendererToHillshade, ); }; };
+		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; settings = {ASSET_TAGS = (ApplyBlendRendererToHillshade, ApplyFunctionToRasterFromFile, ); }; };
+		1CC755E42DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC755E22DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift */; };
+		1CC755E52DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CC755E22DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift */; };
 		218F35B829C28F4A00502022 /* AuthenticateWithOAuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 218F35B329C28F4A00502022 /* AuthenticateWithOAuthView.swift */; };
 		218F35C229C290BF00502022 /* AuthenticateWithOAuthView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 218F35B329C28F4A00502022 /* AuthenticateWithOAuthView.swift */; };
 		3E30884A2C5D789A00ECEAC5 /* SetSpatialReferenceView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 3EEDE7CD2C5D73F700510104 /* SetSpatialReferenceView.swift */; };
@@ -716,6 +719,7 @@
 				3E30884A2C5D789A00ECEAC5 /* SetSpatialReferenceView.swift in Copy Source Code Files */,
 				3E720F9E2C61A0B700E22A9E /* SetInitialViewpointView.swift in Copy Source Code Files */,
 				D78FA4952C3C8E8A0079313E /* CreateDynamicBasemapGalleryView.Views.swift in Copy Source Code Files */,
+				1CC755E52DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift in Copy Source Code Files */,
 				D79482D72C35D8A3006521CD /* CreateDynamicBasemapGalleryView.swift in Copy Source Code Files */,
 				003B36F92C5042BA00A75F66 /* ShowServiceAreaView.swift in Copy Source Code Files */,
 				95ADF34F2C3CBAE800566FF6 /* EditFeatureAttachmentsView.Model.swift in Copy Source Code Files */,
@@ -997,6 +1001,7 @@
 		1C2538522BABACB100337307 /* AugmentRealityToNavigateRouteView.ARSceneView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AugmentRealityToNavigateRouteView.ARSceneView.swift; sourceTree = "<group>"; };
 		1C2538532BABACB100337307 /* AugmentRealityToNavigateRouteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AugmentRealityToNavigateRouteView.swift; sourceTree = "<group>"; };
 		1C26ED152A859525009B7721 /* FilterFeaturesInSceneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterFeaturesInSceneView.swift; sourceTree = "<group>"; };
+		1C293D4B2DCD91BF000B0822 /* color.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = color.json; sourceTree = "<group>"; };
 		1C29C9532DBAE50D0074028F /* AddWMTSLayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWMTSLayerView.swift; sourceTree = "<group>"; };
 		1C38915C2DBC36C700ADFDDC /* AddWFSLayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWFSLayerView.swift; sourceTree = "<group>"; };
 		1C3891602DC02F1100ADFDDC /* ApplyBlendRendererToHillshadeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplyBlendRendererToHillshadeView.swift; sourceTree = "<group>"; };
@@ -1014,6 +1019,7 @@
 		1CAB8D472A3CEAB0002AA649 /* RunValveIsolationTraceView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RunValveIsolationTraceView.swift; sourceTree = "<group>"; };
 		1CAF831B2A20305F000E1E60 /* ShowUtilityAssociationsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowUtilityAssociationsView.swift; sourceTree = "<group>"; };
 		1CC755E02DC5A6A7004B346F /* Shasta_Elevation */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Shasta_Elevation; sourceTree = "<group>"; };
+		1CC755E22DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplyFunctionToRasterFromFileView.swift; sourceTree = "<group>"; };
 		218F35B329C28F4A00502022 /* AuthenticateWithOAuthView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticateWithOAuthView.swift; sourceTree = "<group>"; };
 		3E54CF212C66AFBE00DD2F18 /* AddWebTiledLayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWebTiledLayerView.swift; sourceTree = "<group>"; };
 		3E720F9C2C619B1700E22A9E /* SetInitialViewpointView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetInitialViewpointView.swift; sourceTree = "<group>"; };
@@ -1465,6 +1471,7 @@
 				4C81273A2DCA9E03006EF7D2 /* Apply colormap renderer to raster */,
 				D7F2A02C2CD00F1C0008D981 /* Apply dictionary renderer to feature layer */,
 				D70789912CD160FD000DF215 /* Apply dictionary renderer to graphics overlay */,
+				1CC755E32DC95625004B346F /* Apply function to raster from file */,
 				8810FB572DC94A5600874936 /* Apply function to raster from service */,
 				88E52E6D2DC969CF00F48409 /* Apply hillshade renderer to raster */,
 				955AFAC52C10FD74009C8FE5 /* Apply mosaic rule to rasters */,
@@ -1710,6 +1717,7 @@
 		00CCB8A6285D059300BBAB70 /* Portal Data */ = {
 			isa = PBXGroup;
 			children = (
+				1C293D4C2DCD91BF000B0822 /* 5356dbf91788474493467519e268cf87 */,
 				D762DA0D2D94C750001052DD /* 0fd3a39660d54c12b05d5f81f207dffd */,
 				D74C8C002ABA6202007C76B8 /* 1bd036f221f54a99abc9e46ff3511cbf */,
 				D7781D472B7EB03400E53C51 /* 4caec8c55ea2463982f1af7d9611b8d5 */,
@@ -1974,6 +1982,14 @@
 			path = "Filter features in scene";
 			sourceTree = "<group>";
 		};
+		1C293D4C2DCD91BF000B0822 /* 5356dbf91788474493467519e268cf87 */ = {
+			isa = PBXGroup;
+			children = (
+				1C293D4B2DCD91BF000B0822 /* color.json */,
+			);
+			path = 5356dbf91788474493467519e268cf87;
+			sourceTree = "<group>";
+		};
 		1C29C9622DBAE5D10074028F /* Add WMTS layer */ = {
 			isa = PBXGroup;
 			children = (
@@ -2083,6 +2099,14 @@
 			path = "Show utility associations";
 			sourceTree = "<group>";
 		};
+		1CC755E32DC95625004B346F /* Apply function to raster from file */ = {
+			isa = PBXGroup;
+			children = (
+				1CC755E22DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift */,
+			);
+			path = "Apply function to raster from file";
+			sourceTree = "<group>";
+		};
 		218F35B229C28F4A00502022 /* Authenticate with OAuth */ = {
 			isa = PBXGroup;
 			children = (
@@ -3689,6 +3713,7 @@
 					ApplyColormapRendererToRaster,
 					ApplyDictionaryRendererToFeatureLayer,
 					ApplyDictionaryRendererToGraphicsOverlay,
+					ApplyFunctionToRasterFromFile,
 					ApplyHillshadeRendererToRaster,
 					ApplyRgbRenderer,
 					ApplyScheduledUpdatesToPreplannedMapArea,
@@ -3756,6 +3781,7 @@
 			files = (
 				1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */,
 				D7F8C0412B605E720072BFA7 /* FillmoreTopographicMap.vtpk in Resources */,
+				1C293D4D2DCD91BF000B0822 /* color.json in Resources */,
 				9537AFD72C220EF0000923C5 /* ExchangeSetwithoutUpdates in Resources */,
 				D7F8C03E2B605AF60072BFA7 /* ContingentValuesBirdNests.geodatabase in Resources */,
 				E041AC1E288076A60056009B /* info.css in Resources */,
@@ -3979,6 +4005,7 @@
 				D7ABA2FF2A32881C0021822B /* ShowViewshedFromGeoelementInSceneView.swift in Sources */,
 				E0FE32E728747778002C6ACA /* BrowseBuildingFloorsView.swift in Sources */,
 				954AEDEE2C01332600265114 /* SelectFeaturesInSceneLayerView.swift in Sources */,
+				1CC755E42DC95625004B346F /* ApplyFunctionToRasterFromFileView.swift in Sources */,
 				D7F8C0432B608F120072BFA7 /* AddFeaturesWithContingentValuesView.AddFeatureView.swift in Sources */,
 				D752D95F2A3BCE06003EB25E /* DisplayMapFromPortalItemView.swift in Sources */,
 				004A2BA22BED456500C297CE /* ApplyScheduledUpdatesToPreplannedMapAreaView.swift in Sources */,
diff --git a/Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift b/Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
new file mode 100644
index 000000000..28149b06a
--- /dev/null
+++ b/Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift	
@@ -0,0 +1,72 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: .webMercator
+            )
+        )
+        // Creates a raster with the file URL.
+        let elevationRaster = Raster(fileURL: .shastaElevation)
+        
+        // Creates a raster function.
+        let rasterFunction = RasterFunction(fileURL: .colorRasterFunction)
+        
+        // Sets raster for raster function arguments.
+        if let arguments = rasterFunction.arguments {
+            for name in arguments.rasterNames {
+                arguments.setRaster(elevationRaster, forArgumentNamed: name)
+            }
+        }
+        
+        // Creates a raster from the raster function.
+        let raster = Raster(rasterFunction: rasterFunction)
+        
+        // Creates a raster layer from the raster.
+        let rasterLayer = RasterLayer(raster: raster)
+        rasterLayer.opacity = 0.5
+        
+        map.addOperationalLayer(rasterLayer)
+        return map
+    }()
+    
+    var body: some View {
+        MapView(map: map)
+    }
+}
+
+private extension URL {
+    /// The URL to the Shasta elevation data.
+    static var shastaElevation: URL {
+        Bundle.main.url(forResource: "Shasta_Elevation", withExtension: "tif", subdirectory: "Shasta_Elevation")!
+    }
+    
+    /// The URL to the color raster function JSON.
+    static var colorRasterFunction: URL {
+        Bundle.main.url(forResource: "color", withExtension: "json")!
+    }
+}
+
+#Preview {
+    ApplyFunctionToRasterFromFileView()
+}
diff --git a/Shared/Samples/Apply function to raster from file/README.md b/Shared/Samples/Apply function to raster from file/README.md
new file mode 100644
index 000000000..eceab9dff
--- /dev/null
+++ b/Shared/Samples/Apply function to raster from file/README.md	
@@ -0,0 +1,42 @@
+# Apply function to raster from file
+
+Apply a raster function to a local raster file and display the output with a raster layer.
+
+![Image of Apply function to raster from file sample](apply-function-to-raster-from-file.png)
+
+## Use case
+
+Raster functions allow processing operations that can be applied to one or more rasters on the fly. A land survey agency may apply hillshade and aspect functions to rasters with elevation data in order to better determine the topography of a landscape and to make further planning decisions.
+
+## How to use the sample
+
+Load the sample to see a raster function applied to a raster.
+
+## How it works
+
+1. Create a `RasterFunction` using the path to a local raster function JSON file.
+2. Set the raster function arguments as required by the function used.
+3. Use the raster function to create a new `Raster`.
+4. Set the raster to a `RasterLayer` and display it in the `Map`.
+
+## Relevant API
+
+* Raster
+* RasterFunction
+* RasterLayer
+
+## Offline data
+
+This sample uses the [Shasta Elevation Raster](https://www.arcgis.com/home/item.html?id=b051f5c3e01048f3bf11c59b41507896) and [Color Raster Function](https://www.arcgis.com/home/item.html?id=5356dbf91788474493467519e268cf87). Both are downloaded from ArcGIS Online automatically.
+
+## About the data
+
+The raster function in the provided JSON file blends a color image with a greyscale image (in this case, a raster image containing elevation data), to add a hillshade effect to the input raster.
+
+## Additional information
+
+Learn more about [raster functions](https://pro.arcgis.com/en/pro-app/latest/help/analysis/raster-functions/raster-functions.htm) in the ArcGIS Pro documentation.
+
+## Tags
+
+analysis, function, image, layer, processing, raster, raster function, transformation
diff --git a/Shared/Samples/Apply function to raster from file/README.metadata.json b/Shared/Samples/Apply function to raster from file/README.metadata.json
new file mode 100644
index 000000000..3c2ab4f8e
--- /dev/null
+++ b/Shared/Samples/Apply function to raster from file/README.metadata.json	
@@ -0,0 +1,35 @@
+{
+    "category": "Visualization",
+    "description": "Apply a raster function to a local raster file and display the output with a raster layer.",
+    "ignore": false,
+    "images": [
+        "apply-function-to-raster-from-file.png"
+    ],
+    "keywords": [
+        "analysis",
+        "function",
+        "image",
+        "layer",
+        "processing",
+        "raster",
+        "raster function",
+        "transformation",
+        "Raster",
+        "RasterFunction",
+        "RasterLayer"
+    ],
+    "offline_data": [
+        "b051f5c3e01048f3bf11c59b41507896",
+        "5356dbf91788474493467519e268cf87"
+    ],
+    "redirect_from": [],
+    "relevant_apis": [
+        "Raster",
+        "RasterFunction",
+        "RasterLayer"
+    ],
+    "snippets": [
+        "ApplyFunctionToRasterFromFileView.swift"
+    ],
+    "title": "Apply function to raster from file"
+}
diff --git a/Shared/Samples/Apply function to raster from file/apply-function-to-raster-from-file.png b/Shared/Samples/Apply function to raster from file/apply-function-to-raster-from-file.png
new file mode 100644
index 000000000..a6fd4f670
Binary files /dev/null and b/Shared/Samples/Apply function to raster from file/apply-function-to-raster-from-file.png differ


Reviews:
user: login: des12437
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-07T23:13:57Z
user: login: des12437
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-08T01:10:31Z
user: login: philium
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-08T19:34:31Z
user: login: philium
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-08T19:36:59Z
user: login: yo1995
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-14T00:07:55Z
user: login: des12437
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T00:18:27Z
user: login: des12437
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T00:32:30Z
user: login: des12437
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T00:34:40Z
user: login: des12437
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T00:36:03Z
user: login: yo1995
state: DISMISSED
author_association: COLLABORATOR
submitted_at: 2025-05-14T21:37:04Z
user: login: yo1995
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-14T22:17:35Z
user: login: philium
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T18:33:05Z

Review comments:
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Create a raster with the file URL.
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: des12437
body: ```suggestion
        // Creates a raster with the file URL.
```
Should these comments use active voice? (creates, makes, etc.)
created_at: 2025-05-07T23:13:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -948,6 +952,7 @@
 		1C2538522BABACB100337307 /* AugmentRealityToNavigateRouteView.ARSceneView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AugmentRealityToNavigateRouteView.ARSceneView.swift; sourceTree = "<group>"; };
 		1C2538532BABACB100337307 /* AugmentRealityToNavigateRouteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AugmentRealityToNavigateRouteView.swift; sourceTree = "<group>"; };
 		1C26ED152A859525009B7721 /* FilterFeaturesInSceneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterFeaturesInSceneView.swift; sourceTree = "<group>"; };
+		1C293D062DCC05EE000B0822 /* color.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = color.json; path = "Portal Data/5356dbf91788474493467519e268cf87/color.json"; sourceTree = "<group>"; };
path: Samples.xcodeproj/project.pbxproj
user: login: des12437
body: I may have added the color.json file to the project incorrectly, as when I sort the samples by name to save the project file a new folder `Recovered References` is created containing the color.json file. Can anyone else reproduce this?
created_at: 2025-05-08T01:10:31Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Create a raster with the file URL.
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: philium
body: Yes, I believe that is recommended for samples.
created_at: 2025-05-08T19:34:31Z
author_association: CONTRIBUTOR
diff_hunk: @@ -948,6 +952,7 @@
 		1C2538522BABACB100337307 /* AugmentRealityToNavigateRouteView.ARSceneView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AugmentRealityToNavigateRouteView.ARSceneView.swift; sourceTree = "<group>"; };
 		1C2538532BABACB100337307 /* AugmentRealityToNavigateRouteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AugmentRealityToNavigateRouteView.swift; sourceTree = "<group>"; };
 		1C26ED152A859525009B7721 /* FilterFeaturesInSceneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterFeaturesInSceneView.swift; sourceTree = "<group>"; };
+		1C293D062DCC05EE000B0822 /* color.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = color.json; path = "Portal Data/5356dbf91788474493467519e268cf87/color.json"; sourceTree = "<group>"; };
path: Samples.xcodeproj/project.pbxproj
user: login: philium
body: Yes, I can reproduce that. I think the issue is that `Portal Data/5356dbf91788474493467519e268cf87` has not been added to the project.
created_at: 2025-05-08T19:36:59Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: yo1995
body: ```suggestion
                spatialReference: .webMercator
```
created_at: 2025-05-13T23:54:55Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Creates a raster with the file URL.
+        let elevationRaster = Raster(fileURL: .shastaElevation)
+        
+        // Creates a raster layer from the elevation raster.
+        let rasterLayer = RasterLayer(raster: elevationRaster)
+        rasterLayer.opacity = 0.5
+        
+        // Creates a raster function.
+        let rasterFunction = RasterFunction(fileURL: .colorRasterFunction)
+        
+        // Sets the number of rasters required which is 2 in this case.
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: yo1995
body: ```suggestion
        // Sets the number of rasters required which is 2 in this case.
        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
```
Should this only be set once?
created_at: 2025-05-14T00:02:18Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Creates a raster with the file URL.
+        let elevationRaster = Raster(fileURL: .shastaElevation)
+        
+        // Creates a raster layer from the elevation raster.
+        let rasterLayer = RasterLayer(raster: elevationRaster)
+        rasterLayer.opacity = 0.5
+        
+        // Creates a raster function.
+        let rasterFunction = RasterFunction(fileURL: .colorRasterFunction)
+        
+        // Sets the number of rasters required which is 2 in this case.
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        
+        // Creates a raster from the raster function.
+        let colorRaster = Raster(rasterFunction: rasterFunction)
+        
+        // Creates a raster layer from the raster.
+        let colorRasterLayer = RasterLayer(raster: colorRaster)
+        colorRasterLayer.opacity = 0.5
+        
+        map.addOperationalLayers([rasterLayer, colorRasterLayer])
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: yo1995
body: ```suggestion
        map.addOperationalLayer(colorRasterLayer)
```
Should it only show the raster that has a function applied? If so, the `rasterLayer` can be omitted
created_at: 2025-05-14T00:02:47Z
author_association: COLLABORATOR
diff_hunk: @@ -154,7 +155,9 @@
 		1CAB8D502A3CEB43002AA649 /* RunValveIsolationTraceView.Model.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D442A3CEAB0002AA649 /* RunValveIsolationTraceView.Model.swift */; };
 		1CAB8D512A3CEB43002AA649 /* RunValveIsolationTraceView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D472A3CEAB0002AA649 /* RunValveIsolationTraceView.swift */; };
 		1CAF831F2A20305F000E1E60 /* ShowUtilityAssociationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF831B2A20305F000E1E60 /* ShowUtilityAssociationsView.swift */; };
-		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; };
+		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; settings = {ASSET_TAGS = (ApplyFunctionToRasterFromFile, ); }; };
path: Samples.xcodeproj/project.pbxproj
user: login: yo1995
body: Oops, it seems the ODR tag "ApplyBlendRendererToHillshade" was missing for the other sample [here](https://github.com/Esri/arcgis-maps-sdk-swift-samples/pull/589/files#diff-edb149324ca147e6068a5e155551b365ff9044bd6b606d0a6803dbb928e696fcR157). Can you fix it either in a new PR, or in this PR?
created_at: 2025-05-14T00:06:27Z
author_association: COLLABORATOR
diff_hunk: @@ -154,7 +155,9 @@
 		1CAB8D502A3CEB43002AA649 /* RunValveIsolationTraceView.Model.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D442A3CEAB0002AA649 /* RunValveIsolationTraceView.Model.swift */; };
 		1CAB8D512A3CEB43002AA649 /* RunValveIsolationTraceView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D472A3CEAB0002AA649 /* RunValveIsolationTraceView.swift */; };
 		1CAF831F2A20305F000E1E60 /* ShowUtilityAssociationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF831B2A20305F000E1E60 /* ShowUtilityAssociationsView.swift */; };
-		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; };
+		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; settings = {ASSET_TAGS = (ApplyFunctionToRasterFromFile, ); }; };
path: Samples.xcodeproj/project.pbxproj
user: login: des12437
body: Yes, I will create another PR.
created_at: 2025-05-14T00:18:27Z
author_association: CONTRIBUTOR
diff_hunk: @@ -154,7 +155,9 @@
 		1CAB8D502A3CEB43002AA649 /* RunValveIsolationTraceView.Model.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D442A3CEAB0002AA649 /* RunValveIsolationTraceView.Model.swift */; };
 		1CAB8D512A3CEB43002AA649 /* RunValveIsolationTraceView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 1CAB8D472A3CEAB0002AA649 /* RunValveIsolationTraceView.swift */; };
 		1CAF831F2A20305F000E1E60 /* ShowUtilityAssociationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF831B2A20305F000E1E60 /* ShowUtilityAssociationsView.swift */; };
-		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; };
+		1CC755E12DC5A6A7004B346F /* Shasta_Elevation in Resources */ = {isa = PBXBuildFile; fileRef = 1CC755E02DC5A6A7004B346F /* Shasta_Elevation */; settings = {ASSET_TAGS = (ApplyFunctionToRasterFromFile, ); }; };
path: Samples.xcodeproj/project.pbxproj
user: login: des12437
body: https://github.com/Esri/arcgis-maps-sdk-swift-samples/pull/615
created_at: 2025-05-14T00:32:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Creates a raster with the file URL.
+        let elevationRaster = Raster(fileURL: .shastaElevation)
+        
+        // Creates a raster layer from the elevation raster.
+        let rasterLayer = RasterLayer(raster: elevationRaster)
+        rasterLayer.opacity = 0.5
+        
+        // Creates a raster function.
+        let rasterFunction = RasterFunction(fileURL: .colorRasterFunction)
+        
+        // Sets the number of rasters required which is 2 in this case.
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        
+        // Creates a raster from the raster function.
+        let colorRaster = Raster(rasterFunction: rasterFunction)
+        
+        // Creates a raster layer from the raster.
+        let colorRasterLayer = RasterLayer(raster: colorRaster)
+        colorRasterLayer.opacity = 0.5
+        
+        map.addOperationalLayers([rasterLayer, colorRasterLayer])
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: des12437
body: Yes, the raster layer can be removed.
created_at: 2025-05-14T00:34:39Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Creates a raster with the file URL.
+        let elevationRaster = Raster(fileURL: .shastaElevation)
+        
+        // Creates a raster layer from the elevation raster.
+        let rasterLayer = RasterLayer(raster: elevationRaster)
+        rasterLayer.opacity = 0.5
+        
+        // Creates a raster function.
+        let rasterFunction = RasterFunction(fileURL: .colorRasterFunction)
+        
+        // Sets the number of rasters required which is 2 in this case.
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: des12437
body: Setting the raster once causes the color raster to not show on the map, so setting it twice is necessary.
created_at: 2025-05-14T00:36:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,73 @@
+// Copyright 2025 Esri
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import ArcGIS
+import SwiftUI
+
+struct ApplyFunctionToRasterFromFileView: View {
+    /// A map with an imagery basemap style and raster layers.
+    @State private var map: Map = {
+        let map = Map(basemapStyle: .arcGISImageryStandard)
+        map.initialViewpoint = Viewpoint(
+            boundingGeometry: Envelope(
+                xRange: -13606233.44023646 ... -13591503.517810356,
+                yRange: 4971762.696708013...4982810.138527592,
+                spatialReference: SpatialReference(wkid: .init(102100)!)
+            )
+        )
+        // Creates a raster with the file URL.
+        let elevationRaster = Raster(fileURL: .shastaElevation)
+        
+        // Creates a raster layer from the elevation raster.
+        let rasterLayer = RasterLayer(raster: elevationRaster)
+        rasterLayer.opacity = 0.5
+        
+        // Creates a raster function.
+        let rasterFunction = RasterFunction(fileURL: .colorRasterFunction)
+        
+        // Sets the number of rasters required which is 2 in this case.
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
+        rasterFunction.arguments?.setRaster(elevationRaster, forArgumentNamed: "raster")
path: Shared/Samples/Apply function to raster from file/ApplyFunctionToRasterFromFileView.swift
user: login: yo1995
body: I see. I'm OK with the current solution, but I don't understand how the raster function works to distinguish these 2 `setRaster` calls with the same argument name… 😵‍💫 
One alternative I can think of is sth like this

```swift
        if let arguments = rasterFunction.arguments {
            for name in arguments.rasterNames {
                arguments.setRaster(elevationRaster, forArgumentNamed: name)
            }
        }
```
created_at: 2025-05-14T21:31:33Z
author_association: COLLABORATOR

PR comments:
user: login: des12437
created_at: 2025-05-13T22:18:12Z
body: This PR is ready for review.
author_association: CONTRIBUTOR
user: login: des12437
created_at: 2025-05-16T17:55:26Z
body: @philium Can you please review this PR when you have a chance? Thanks!
author_association: CONTRIBUTOR