ArcGIS Pro 改变栅格的数据源
var rasterLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<RasterLayer>().FirstOrDefault(); QueuedTask.Run(async () => { using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"\\Path-to-Data\raster.gdb")))) { using (Dataset dataset = geodatabase.OpenDataset<RasterDataset>("elevation")) { rasterLayer.ReplaceDataSource(dataset); // Check if the Stretch colorizer can be applied to the raster layer. if (rasterLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer)) { // Create a new Stretch Colorizer Definition using the default constructor. StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition(); // Create a new Stretch colorizer using the colorizer definition created above. CIMRasterStretchColorizer newStretchColorizer_default = await rasterLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer; // Set the new colorizer on the raster layer. rasterLayer.SetColorizer(newStretchColorizer_default); } } } });