Raster data provides a unique way to analyze and visualize geographic phenomena. Rasters consist of a matrix of cells, with each cell containing a value. Rasters can have multiple dimensions or bands, for example, the red, green, and blue channels in an aerial photo. Rasters are different from vectors, which use points, lines, and polygons to represent features. For more information on raster data, including advantages and disadvantages of using it, see What is raster data? and Imagery and raster in ArcGIS Pro in the ArcGIS Desktop help.
Raster data is represented by the Raster class. Your app can work with many sources of raster data including raster files, mosaic datasets, raster data shared through image services, or the results of raster functions. A raster function can take any of these rasters as input for analysis.
The Raster object implements the loadable pattern described in Loading resources asynchronously and asynchronously accesses raster data from remote services or datasets.
Raster data supports the identify operation to obtain RasterCell values when a user clicks on a pixel in a MapView or SceneView for RasterLayers.
Create a raster from a raster file
To add raster files stored on your desktop or device to your app, create a Raster object using the path of the raster file.
A GeoPackage is an open, standards-based, platform-independent, portable, self-describing, compact format for transferring geospatial information. It is a platform-independent SQLite database file that contains data and metadata tables. For details, refer to the OGC GeoPackage specification. You can read a local GeoPackage and load the feature tables and rasters that it contains.
Open a GeoPackage using the path to the .gpkg file. The GeoPackageRasters property returns a collection of all rasters in the package. You can work with a GeoPackageRaster as you would any other Raster, including adding it as a RasterLayer to your app's map.
Raster data stored in a mobile mosaic dataset should be read through the MosaicDatasetRaster, which inherits from Raster. The MosaicDatasetRaster object is instantiated with a path of the mobile geodatabase and a name of the dataset.
Create a mobile mosaic dataset and add raster files
MosaicDatasetRaster can also be used to create a mobile mosaic dataset in a new mobile geodatabase and save it to the device. After the mobile mosaic dataset is created, individual raster files can be asynchronously added to it. The mobile geodatabase is created when the MosaicDatasetRaster is loaded successfully.
Use the AddRastersParameters class to perform tasks, such as the following:
Set the input directory containing the raster files to be added
Control other properties of the mosaic, such as minimum and maximum pixel sizes
Create a raster from an image service
Raster and image data can be shared as an image service using ArcGIS Server. An image service provides access to raster data through a web service. A single raster dataset or a mosaic dataset that contains a collection of raster datasets can be served as one image service. The mosaic dataset can dynamically process and mosaic the images on the fly. An image service supports accessing both the mosaicked image and its catalog, as well as individual rasters in the catalog. For more information on image services, see Key concepts for image services in the ArcGIS help.
Use the ImageServiceRaster class to work with image services in your app. You can create an ImageServiceRaster with the URL of an image service. And if you want to display the raster data on a map, create a raster layer for it.
For mosaicked images, a mosaic rule defines how the individual rasters are combined. You can use the default rule defined with the service or, starting with 100.9.0, define rule settings to control how overlapping areas in the mosaic are handled. In addition to how it's displayed, the mosaic rule may effect values returned when identifying, computing a histogram, or exporting the image.
ImageServiceRaster is a subclass of Raster, so any operation that can be applied to the Raster class, such as raster functions, can also be applied to ImageServiceRaster. Besides the common properties inherited from the Raster class, ImageServiceRaster has additional properties and capabilities, such as the image service metadata and rendering rules. After the image service raster has been loaded, the metadata of the image service can be retrieved through the service info property, which is represented by ArcGISImageServiceInfo. However, only a subset of the metadata, including attribution text and a list of information on predefined service rendering rules, is exposed by this API. For more information on the metadata of an image service, see Image Service in the ArcGIS services reference.
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Create an image service raster from a URIvar imageServerUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/CharlotteLAS/ImageServer");
ImageServiceRaster serviceRaster = new ImageServiceRaster(imageServerUri);
// When the image service raster loads, the service info and rendering rule info will be availableserviceRaster.Loaded += (s, e) =>
{
// Get service info ArcGISImageServiceInfo serviceInfo = serviceRaster.ServiceInfo;
// Get rendering rule info list IReadOnlyList<RenderingRuleInfo> renderingRuleInfos = serviceInfo.RenderingRuleInfos;
// Load the raster with one of the rules// (Note: the rendering rule cannot be set on an ImageServiceRaster that is already loaded) RenderingRule myRenderingRule = new RenderingRule(renderingRuleInfos[3]);
// Create a new image service raster ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(imageServerUri)
{
// Set the image service raster's rendering rule to the rendering rule created earlier RenderingRule = myRenderingRule
};
// Call a function to create and add a raster layer to the map _ = AddRasterLayer(myImageServiceRaster);
};
// Load the image service rasterserviceRaster.LoadAsync();
Create a raster from a raster function
Raster functions can be applied to a raster to process that data. This processing is not permanently applied to the data; instead, it is applied on the fly as the rasters are accessed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Create a new hillshade raster function from a JSON definition (stored in a text file).var hillshadeFunction = new RasterFunction(pathToHillshadeFunctionJSON);
// Get the function's arguments.RasterFunctionArguments rasterFunctionArguments = hillshadeFunction.Arguments;
// Assuming rasterNames has 1 entry, set the input raster.IReadOnlyList<string> rasterNames = rasterFunctionArguments.GetRasterNames();
var inputRaster = new Raster(pathToInputTIF);
rasterFunctionArguments.SetRaster(rasterNames[0], inputRaster);
// Create a new raster based on the function.Raster raster = new Raster(hillshadeFunction);
// Create a RasterLayer to display the Raster, add it to the map.RasterLayer rasterLayer = new RasterLayer(raster);
MyMapView.Map = new Map(new Basemap(rasterLayer));
Supported Raster functions
The supported raster functions are detailed in this section, along with the syntax for using them. Note that the syntax is similar to the ArcGIS REST syntax for the same functions but is not exactly the same.
The general syntax for raster functions is the following:
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
{
"raster_function":{"type":"<Raster Function Name>"},
"raster_function_arguments":
{
"argument1":"<JSON Value Object>",
"argument2":"<JSON Value Object>",
"argumentN":"<JSON Value Object>",
"type":"Raster_function_arguments" },
"type":"Raster_function_template"}
It's not necessary to display the raster data you work with in your app. However, if you want your users to view raster data on a map, add the raster using the RasterLayer class. RasterLayer can render raster data from any type of raster. See Layers for more information about creating and working with raster layers.
You can add a raster layer to a map as either a basemap or an operational layer. When adding a raster layer as an operational layer to a map with different spatial reference, the layer will be reprojected on the fly and added to the map.
Supported raster formats
This API supportes a subset of raster file formats that ArcGIS Desktop supports. The supported raster file formats include: