An image overlay is useful for displaying fast and dynamic images; for example, rendering real-time sensor data captured from a drone. Each frame from the drone becomes a static image which is updated on the fly as the data is made available.
How to use the sample
The application loads a map of the Southwestern United States. Click the "Start" or "Stop" buttons to start or stop the radar animation. Use the drop down menu to select how quickly the animation plays. Move the slider to change the opacity of the image overlay.
How it works
Create an ImageOverlay and add it to the SceneView.
Set up a timer with an initial interval time of 68ms, which will display approximately 15 ImageFrames per second.
Connect to the timeout signal from the timer.
Create a new image frame every timeout and set it on the image overlay.
These radar images were captured by the US National Weather Service (NWS). They highlight the Pacific Southwest sector which is made up of part the western United States and Mexico. For more information visit the National Weather Service website.
Additional information
The supported image formats are GeoTIFF, TIFF, JPEG, and PNG. ImageOverlay does not support the rich processing and rendering capabilities of a RasterLayer. Use Raster and RasterLayer for static image rendering, analysis, and persistence.
Tags
3d, animation, drone, dynamic, image frame, image overlay, real time, rendering
Sample Code
AnimateImagesWithImageOverlay.qml
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// [WriteFile Name=AnimateImagesWithImageOverlay, Category=Scenes]// [Legal]// Copyright 2020 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// http://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.// [Legal]import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Esri.ArcGISRuntime
import Esri.ArcGISExtras
Rectangle {
id: rootRectangleclip: truewidth: 800height: 600 readonly property var timerIntervals: [17,34,68]
readonly property var imageFrameRefreshRate: ["Fast","Medium","Slow"]
readonly property url dataPath: {
Qt.platform.os === "ios" ?
System.writableLocationUrl(System.StandardPathsDocumentsLocation) + "/ArcGIS/Runtime/Data/3D/ImageOverlay/PacificSouthWest" :
System.writableLocationUrl(System.StandardPathsHomeLocation) + "/ArcGIS/Runtime/Data/3D/ImageOverlay/PacificSouthWest" }
property int fileNamesLength: 0property var imageFrameList: []
// free up memory claimed by imageFrameList propertyComponent.onDestruction: {
imageFrameList = [];
}
// Create new Timer and set the timeout interval to 68msTimer {
id: timerinterval: 68repeat: trueproperty var index: 0// connect to the triggered signal to load and display a new image frame each timeonTriggered: {
// check if images are found before trying to load themif (fileNamesLength === 0)
return;
// Create new ImageFrames from images in the folder// Add them to a list so infinite ImageFrame objects are not created each loopif (imageFrameList.length !== fileNamesLength) {
imageFrameList.push(ArcGISRuntimeEnvironment.createObject("ImageFrame", {
url: dataPath + "/" + imageFrameFolder.fileNames()[index],
extent: imageFrameExtent
}));
}
// set image frame to image overlay imageOverlay.imageFrame = imageFrameList[index];
// increment the index to keep track of which image to load next index++;
// reset index once all files have been loadedif (index === fileNamesLength) {
index = 0;
}
}
}
SceneView {
id: sceneViewanchors.fill: parentComponent.onCompleted: {
// Set the focus on SceneView to initially enable keyboard navigation forceActiveFocus();
}
Scene {
id: sceneSurface {
// create a new elevation source from Terrain3D REST serviceArcGISTiledElevationSource {
url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" }
}
// create a new tiled layer from World_Dark_Gray_Base REST serviceArcGISTiledLayer {
id: worldDarkGrayBasemapurl: "https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer" }
// set an initial viewpointViewpointExtent {
Point {
id: initialViewpointx: -116.621y: 24.7773z: 856977spatialReference: SpatialReference { wkid: 4326 }
}
// create a camera, looking at the pacific southwest sectorCamera {
id: cameralocation: initialViewpoint
heading: 353.994pitch: 48.5495roll: 0 }
}
}
ImageOverlay {
id: imageOverlay }
Rectangle {
id: controlsRectanchors {
bottom: sceneView.attributionTop
horizontalCenter: parent.horizontalCenter
}
width: childrenRect.width
height: childrenRect.height
color: "lightgrey"opacity: 0.8radius: 5ColumnLayout {
id: controlsLayoutLayout.alignment: Qt.AlignBottom
spacing: 0Slider {
id: opacitySliderfrom: 0to: 1value: 1Layout.preferredHeight: bottomRowControls.height
Layout.alignment: Qt.AlignHCenter
onMoved: imageOverlay.opacity = value;
// Custom slider handle that displays the current valuehandle: Item {
x: parent.leftPadding + parent.visualPosition * (parent.availableWidth - headingHandleNub.width)
y: parent.topPadding + parent.availableHeight / 2 - headingHandleNub.height / 2Rectangle {
id: headingHandleNubcolor: headingHandleRect.color
radius: width * 0.5width: 20height: width
}
Rectangle {
id: headingHandleRectheight: childrenRect.height
width: childrenRect.width
radius: 3x: headingHandleNub.x - width / 2 + headingHandleNub.width / 2y: headingHandleNub.y - height
color: opacitySlider.background.children[0].color
Text {
id: headingValuefont.pixelSize: 14padding: 3horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
text: "opacity: " + (opacitySlider.value).toFixed(2)
color: "white" }
}
}
}
RowLayout {
id: bottomRowControlsspacing: 2Button {
id: startStopBtntext: !timer.running ? qsTr("Start") : qsTr("Stop")
Layout.minimumWidth: timerIntervalComboBox.width
onClicked: {
if (!timer.running)
timer.start();
else timer.stop();
}
}
ComboBox {
id: timerIntervalComboBoxcurrentIndex: 2model: imageFrameRefreshRate
Layout.minimumWidth: startStopBtn.width
onActivated: timer.interval = timerIntervals[currentIndex];
}
}
}
}
}
// create an envelope of the pacific southwest sector for displaying the image frameEnvelope {
id: imageFrameExtentxMin: -127.62xMax: -112.524yMin: 27.9425yMax: 42.3195spatialReference: SpatialReference { wkid: 4326 }
}
// Create file folder to find image file namesFileFolder {
id: imageFrameFolderurl: dataPath
Component.onCompleted: fileNamesLength = imageFrameFolder.fileNames().length;
}
}