Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- await QueuedTask.Run(() => {
- string outputFolderName = "folderName";
- string rasterName = "name.tiff";
- string rasterFormat = "TIFF";
- Raster raster = currentRasterLayer.GetRaster();
- //create output directory and a new datastore
- string outputFolder = Path.Combine(Project.Current.HomeFolderPath, ouputFolderName);
- Directory.CreateDirectory(outputFolder);
- FileSystemConnectionPath outputConnectionPath = new FileSystemConnectionPath(
- new System.Uri(outputFolder), FileSystemDatastoreType.Raster);
- FileSystemDatastore outputDataStore = new FileSystemDatastore(outputConnectionPath);
- //create a copy of the opened raster
- RasterDataset resultRasterDataset = raster.SaveAs(rasterName, outputDataStore, rasterFormat);
- Raster resultRaster = resultRasterDataset.CreateFullRaster();
- if (!resultRaster.CanEdit()) {
- MessageBox.Show("Cannot edit raster");
- return;
- }
- PixelBlock pixelBlock = resultRaster.CreatePixelBlock(resultRaster.GetWidth(), resultRaster.GetHeight());
- pixelBlock.Clear(0);
- resultRaster.Write(0, 0, pixelBlock);
- resultRaster.Refresh();
- });
Add Comment
Please, Sign In to add comment