Hi,
The following Guide topics will help explain:
- Build a new scene—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
- Add raster data—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
Thanks
Mike
Hi, Michael. Thank you for answer. But i didnt catch anything from this. I have a TIFF file path C:\Users\user123\Documents\ArcGIS\11062020\TopoToR_N46E11 and want to create 3d surface in wpf app using this file. Could you please show code example in my case? Thank you)
I tried this one from your link:
<SPAN class="" style="color: #006a00;">// create a new scene with a topographic basemap</SPAN><SPAN class="" style="color: #aa0d91;">var</SPAN> myScene = <SPAN class="" style="color: #aa0d91;">new</SPAN> Scene(Basemap.CreateTopographic()); <SPAN class="" style="color: #006a00;">// add the new scene to the scene view</SPAN>MySceneView.Scene = myScene;
Add an elevation surface and apply it to the scene.
<SPAN class="" style="color: #006a00;"> // create an elevation source</SPAN><SPAN class="" style="color: #aa0d91;">var</SPAN> elevationSource = <SPAN class="" style="color: #aa0d91;">new</SPAN> ArcGISTiledElevationSource(<SPAN class="" style="color: #aa0d91;">new</SPAN> System.Uri(<SPAN class="" style="color: #c41a16;">"C:\\Users\\user123\\Documents\\ArcGIS\\11062020\\TopoToR_N46E11.tiff"</SPAN>)); //-----added my filepath to tiff file<SPAN class="" style="color: #006a00;">// create a surface and add the elevation surface</SPAN><SPAN class="" style="color: #aa0d91;">var</SPAN> sceneSurface = <SPAN class="" style="color: #aa0d91;">new</SPAN> Surface(); sceneSurface.ElevationSources.Add(elevationSource); <SPAN class="" style="color: #006a00;">// apply the surface to the scene</SPAN>MySceneView.Scene.BaseSurface = sceneSurface; And it doesn't work(
Does it work if you use the RasterElevationSource Class?
The tiled elevation source should be used when you have elevation encoded tile packages (Share a tile package—ArcGIS Pro | Documentation).
If somebody is interested in. There is my solution that works. it is made on mvvm like pattern
First. Class SceneViewmodel:
public class SceneViewModel : UserControl, INotifyPropertyChanged { public SceneViewModel() { CreateNewScene(); }
Scene _scene;
/// <summary> /// Gets or sets the map /// </summary>
public Scene Scene { get { return _scene; } set { _scene = value; OnPropertyChanged(); } }
/// <summary> /// Raises the <see cref="MapViewModel.PropertyChanged" /> event /// </summary> /// <param name="propertyName">The name of the property that has changed</param> protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { var propertyChangedHandler = PropertyChanged; if (propertyChangedHandler != null) propertyChangedHandler(this, new PropertyChangedEventArgs(propertyName)); }
public event PropertyChangedEventHandler PropertyChanged;
private async void CreateNewScene() {
Scene newScene = new Scene(Basemap.CreateImagery());
RasterElevationSource elevationSource = new RasterElevationSource(new[] { @C:\Users\user\Downloads\tif3dmap1.tif ,@C:\Users\user\Downloads\tif3dmap2.tif }); await elevationSource.LoadAsync(); Surface elevationSurface = new Surface(); elevationSurface.ElevationSources.Add(elevationSource); elevationSurface.ElevationExaggeration =20;//depends on how deep relief on the surface you want
await elevationSurface.LoadAsync();
newScene.BaseSurface = elevationSurface; Scene = newScene; Scene.InitialViewpoint = new Viewpoint(elevationSource.FullExtent);
}
Second. MainWindow.xaml.cs:
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var SceneViewModel = new SceneViewModel(); this.DataContext = SceneViewModel; }
Third. MainWindow.xaml:
<Window x:Class="ArcGISApp5.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" xmlns:local="clr-namespace:ArcGISApp5" mc:Ignorable="d" Title="MainWindow" Height="525" Width="790"> <Window.Resources> <local:SceneViewModel x:Key="SceneViewModel" /> </Window.Resources> <Grid><esri:SceneView x:Name ="MySceneView" Scene="{Binding Scene}" > </esri:SceneView><Border Background="White" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="30" Padding="20" Width="355"> <Border.Effect> <DropShadowEffect/> </Border.Effect> <StackPanel> <TextBlock x:Name="ScreenCoordsTextBlock" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" Text="Screen Coords: " TextWrapping="Wrap" FontWeight="Bold" /> <TextBlock x:Name="MapCoordsTextBlock" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" Text="Map Coords: " TextWrapping="Wrap" FontWeight="Bold" /> </StackPanel> </Border> </Grid>
</Window>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.