Visualize changes in rasters over time by filtering a mosaic dataset raster for a selected timestamp.

Use case
A mosaic dataset can contain rasters collected over the same area at different times. Viewing the imagery one timestamp at a time makes it easier to compare how a place has changed, such as when tracking urban development, changes in vegetation, or the effects of a natural event.
How to use the sample
When the sample starts, the mosaic dataset raster is displayed in a map view and the available acquisition timestamps are loaded. Use the previous and next controls to step through the distinct timestamps in chronological order. Use the first and last controls to jump to the earliest and latest timestamps. The currently selected timestamp is shown in UTC, and the map view updates to display imagery for that time. Use the slider to adjust the opacity of the raster layer to compare it to the imagery basemap.
How it works
- Create a
Mapand display it in aMapView. - Create and load a
MosaicDatasetRasterfrom the sample mobile mosaic dataset and use it to create aRasterLayer. - Add the raster layer to the map.
- Get the raster’s distinct timestamps using
GetDistinctTimestampsAsync. - Create a
TimeExtentwith a time instant of the initial timestamp and set it on the map view. - Update the time extent on the map view when the selected timestamp changes.
Relevant API
- ITimeAware
- Map
- MapView
- MosaicDatasetRaster
- RasterLayer
Offline data
This sample downloads the following item from ArcGIS Online automatically:
- ElToroMosaicDataset.zip - Mobile mosaic dataset containing imagery of El Toro across multiple acquisition timestamps.
About the data
The sample uses a mobile mosaic dataset ElToroMosaicDataset containing imagery rasters for one local area across multiple acquisition timestamps.
Tags
aerial imagery, date, mosaic dataset, raster, time, time extent, time-aware, time-enabled, timestamp
Sample code
// Copyright 2026 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.
using ArcGIS.Samples.Managers;using Esri.ArcGISRuntime;using Esri.ArcGISRuntime.Mapping;using Esri.ArcGISRuntime.Rasters;using System;using System.Collections.Generic;using System.Globalization;using System.Linq;using System.Threading.Tasks;using System.Windows;
namespace ArcGIS.WPF.Samples.FilterMosaicDatasetRasterByTimeExtent{ [ArcGIS.Samples.Shared.Attributes.Sample( name: "Filter mosaic dataset raster by time extent", category: "MapView", description: "Visualize changes in rasters over time by filtering a mosaic dataset raster for a selected timestamp.", instructions: "When the sample starts, the mosaic dataset raster is displayed in a map view and the available acquisition timestamps are loaded. Use the previous and next controls to step through the distinct timestamps in chronological order. Use the first and last controls to jump to the earliest and latest timestamps. The currently selected timestamp is shown in UTC, and the map view updates to display imagery for that time. Use the slider to adjust the opacity of the raster layer to compare it to the imagery basemap.", tags: new[] { "aerial imagery", "date", "mosaic dataset", "raster", "time", "time extent", "time-aware", "time-enabled", "timestamp" })] [ArcGIS.Samples.Shared.Attributes.OfflineData("5d1c805850054a098667cdb217d76476")] public partial class FilterMosaicDatasetRasterByTimeExtent { private RasterLayer _rasterLayer; private IReadOnlyList<DateTimeOffset> _timestamps = Array.Empty<DateTimeOffset>(); private int _selectedIndex;
public FilterMosaicDatasetRasterByTimeExtent() { InitializeComponent(); _ = Initialize(); }
private async Task Initialize() { try { // Display an imagery basemap for comparison with the historic rasters. MyMapView.Map = new Map(BasemapStyle.ArcGISImageryStandard);
// Load the mosaic dataset from the downloaded mobile geodatabase. string databasePath = DataManager.GetDataFolder( "5d1c805850054a098667cdb217d76476", "el_toro.geodatabase"); string rasterName = MosaicDatasetRaster.GetNames(databasePath).First(); MosaicDatasetRaster raster = new MosaicDatasetRaster(databasePath, rasterName); await raster.LoadAsync();
// Create and load a raster layer, then add it to the map. _rasterLayer = new RasterLayer(raster); await _rasterLayer.LoadAsync(); MyMapView.Map.OperationalLayers.Add(_rasterLayer);
// The distinct timestamps are sorted chronologically. Stepping through them // avoids time ranges with no imagery when acquisitions are irregular. _timestamps = (await raster.GetDistinctTimestampsAsync()).ToList();
// Set the initial viewpoint to the mosaic dataset's full extent. await MyMapView.SetViewpointGeometryAsync(_rasterLayer.FullExtent, 100);
if (_timestamps.Count > 0) { SelectTimestamp(0); } else { TimestampText.Text = "No timestamps available"; }
OpacitySlider.IsEnabled = true; } catch (Exception ex) { TimestampText.Text = "Unable to load raster"; MessageBox.Show(ex.Message, "Error"); } }
private void SelectTimestamp(int index) { _selectedIndex = index;
// An instant uses the same start and end time to show only that acquisition. MyMapView.TimeExtent = new TimeExtent(_timestamps[index]); TimestampText.Text = _timestamps[index].UtcDateTime.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
FirstButton.IsEnabled = PreviousButton.IsEnabled = index > 0; NextButton.IsEnabled = LastButton.IsEnabled = index < _timestamps.Count - 1; }
private void FirstButton_Click(object sender, RoutedEventArgs e) { SelectTimestamp(0); }
private void PreviousButton_Click(object sender, RoutedEventArgs e) { SelectTimestamp(_selectedIndex - 1); }
private void NextButton_Click(object sender, RoutedEventArgs e) { SelectTimestamp(_selectedIndex + 1); }
private void LastButton_Click(object sender, RoutedEventArgs e) { SelectTimestamp(_timestamps.Count - 1); }
private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { if (_rasterLayer != null) { double opacity = Math.Round(e.NewValue, 2); _rasterLayer.Opacity = opacity; OpacityValue.Text = opacity.ToString("P0", CultureInfo.InvariantCulture); } } }}<UserControl x:Class="ArcGIS.WPF.Samples.FilterMosaicDatasetRasterByTimeExtent.FilterMosaicDatasetRasterByTimeExtent" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"> <Grid> <esri:MapView x:Name="MyMapView" /> <Border Style="{StaticResource BorderStyle}"> <StackPanel> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Button x:Name="FirstButton" Width="40" Margin="0,0,4,0" AutomationProperties.Name="First timestamp" Click="FirstButton_Click" Content="|<" IsEnabled="False" /> <Button x:Name="PreviousButton" Grid.Column="1" Width="40" AutomationProperties.Name="Previous timestamp" Click="PreviousButton_Click" Content="<" IsEnabled="False" /> <TextBlock x:Name="TimestampText" Grid.Column="2" Margin="4,0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Loading..." /> <Button x:Name="NextButton" Grid.Column="3" Width="40" AutomationProperties.Name="Next timestamp" Click="NextButton_Click" Content=">" IsEnabled="False" /> <Button x:Name="LastButton" Grid.Column="4" Width="40" Margin="4,0,0,0" AutomationProperties.Name="Last timestamp" Click="LastButton_Click" Content=">|" IsEnabled="False" /> </Grid> <Grid Margin="0,12,0,0"> <TextBlock Text="Opacity" /> <TextBlock x:Name="OpacityValue" HorizontalAlignment="Right" Text="100%" /> </Grid> <Slider x:Name="OpacitySlider" Margin="0,5,0,0" AutomationProperties.Name="Raster opacity" IsEnabled="False" IsSnapToTickEnabled="True" Maximum="1" Minimum="0" SmallChange="0.01" TickFrequency="0.01" Value="1" ValueChanged="OpacitySlider_ValueChanged" /> </StackPanel> </Border> </Grid></UserControl>