QueuedTask.Run(() => { //Open the raster dataset on disk and create a compressed raster value dataset object var dataStore = new ArcGIS.Core.Data.FileSystemDatastore(new ArcGIS.Core.Data.FileSystemConnectionPath(new System.Uri(@"e:\temp"), ArcGIS.Core.Data.FileSystemDatastoreType.Raster)); using (var fileRasterDataset = dataStore.OpenDataset<ArcGIS.Core.Data.Raster.RasterDataset>("Hydrant.jpg")) { var storageDef = new ArcGIS.Core.Data.Raster.RasterStorageDef(); storageDef.SetCompressionType(ArcGIS.Core.Data.Raster.RasterCompressionType.JPEG); storageDef.SetCompressionQuality(90); var rv = new ArcGIS.Core.Data.Raster.RasterValue(); rv.SetRasterDataset(fileRasterDataset); rv.SetRasterStorageDef(storageDef); var sel = MapView.Active.Map.GetSelection(); //insert a raster value object into the raster field var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); insp["Photo"] = rv; var op = new EditOperation() { Name = "Raster Inspector" }; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } } });
QueuedTask.Run(() => { //Open the raster dataset on disk and create a compressed raster value dataset object var dataStore = new ArcGIS.Core.Data.FileSystemDatastore(new ArcGIS.Core.Data.FileSystemConnectionPath(new System.Uri(@"e:\temp"), ArcGIS.Core.Data.FileSystemDatastoreType.Raster)); using (var fileRasterDataset = dataStore.OpenDataset<ArcGIS.Core.Data.Raster.RasterDataset>("Hydrant.jpg")) { var storageDef = new ArcGIS.Core.Data.Raster.RasterStorageDef(); storageDef.SetCompressionType(ArcGIS.Core.Data.Raster.RasterCompressionType.JPEG); storageDef.SetCompressionQuality(90); var rv = new ArcGIS.Core.Data.Raster.RasterValue(); rv.SetRasterDataset(fileRasterDataset); rv.SetRasterStorageDef(storageDef); var sel = MapView.Active.Map.GetSelection(); //insert a raster value object into the raster field var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); insp["Photo"] = rv; var op = new EditOperation() { Name = "Raster Inspector" }; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } } });
Target Platforms: Windows 11, Windows 10