第一张图是QGIS的像元范围300-10000,第二张是。net的范围,要小很多,导入进去,可视化的图明显不对


private void tiffImport_btn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
//判断有没有数据源
if (workspace1.Datasources.Count == 0)
{
MessageBox.Show("请打开一个数据源", "提示");
return;
}
//获取数据源,给数据集赋名字
Datasource datasourse1 = workspace1.Datasources[0];
//根据路径找数据集
this.openFileDialog1.Title = "Import Tiff file";
this.openFileDialog1.InitialDirectory = Application.StartupPath;
this.openFileDialog1.Filter = "Tif file data(*.tif)|*.tif";
this.openFileDialog1.FileName = "";
//判断所在文件路径是否有tiff
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
// 获取导入文件的名称(去除扩展名)
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.openFileDialog1.FileName);
if (datasourse1.Datasets.Contains(fileNameWithoutExtension))
{
datasourse1.Datasets.Delete(fileNameWithoutExtension);
}
//有数据集然后把数据集导入,从数据源到数据集依次
DataImport dataimport = new DataImport();
ImportSettingTIF importSettingtif = new ImportSettingTIF();
importSettingtif.SourceFilePath = this.openFileDialog1.FileName; // 设置源文件路径
importSettingtif.TargetDatasetName = fileNameWithoutExtension; // 使用文件名作为目标数据集名称
importSettingtif.ImportingAsGrid = true;
string orientation_name = fileNameWithoutExtension;
importSettingtif.TargetDatasource = datasourse1; // 设置目标数据源
importSettingtif.MultiBandImportMode = MultiBandImportMode.Composite; // 设置复合模式
dataimport.ImportSettings.Add(importSettingtif);
// 执行导入操作
ImportResult result = dataimport.Run();
// 判断是否成功导入
if (result.SucceedSettings.Length > 0)
{
MessageBox.Show("导入成功", "提示");
datasourse1.Refresh();
// 使用文件名作为数据集名称,获取导入后的数据集
orientation_DatasetGrid = datasourse1.Datasets[fileNameWithoutExtension] as DatasetGrid;
Colors colors2 = new Colors();
// 红色起点
colors2.Add(Color.FromArgb(255, 0, 0)); // 纯红
// 向橙色过渡
colors2.Add(Color.FromArgb(255, 55, 0));
colors2.Add(Color.FromArgb(255, 115, 0));
colors2.Add(Color.FromArgb(255, 225, 0));
// 橙色到黄色
colors2.Add(Color.FromArgb(255, 255, 0)); // 纯黄
// 黄色向绿黄色过渡
colors2.Add(Color.FromArgb(131, 207, 0)); // 绿黄色
// 向绿色过渡
colors2.Add(Color.FromArgb(0, 255, 0)); // 纯绿
// 绿色向青色过渡
colors2.Add(Color.FromArgb(0, 255, 100)); // 带绿的青色
colors2.Add(Color.FromArgb(0, 255, 150)); // 更深一点的青色
colors2.Add(Color.FromArgb(0, 255, 200)); // 接近纯青色
// 青色向蓝色过渡
colors2.Add(Color.FromArgb(0, 200, 255)); // 带青的蓝
colors2.Add(Color.FromArgb(0, 150, 255)); // 中等蓝
colors2.Add(Color.FromArgb(0, 100, 255)); // 更深的蓝
colors2.Add(Color.FromArgb(0, 50, 255)); // 接近纯蓝但带一点青
// 蓝色终点
colors2.Add(Color.FromArgb(0, 0, 255)); // 纯蓝
orientation_DatasetGrid.ColorTable = colors2;
mapControl1.Map.Refresh();
workspacetree1.Refresh();
if (orientation_DatasetGrid != null)
{
// 将导入的数据集添加到地图上
mapControl1.Map.Layers.Add(orientation_DatasetGrid, true);
mapControl1.Map.ViewEntire();
mapControl1.Map.Refresh();
}
else
{
select_datasource.Datasets.Delete(fileNameWithoutExtension);
MessageBox.Show("数据集转换失败", "错误");
}
}
else
{
MessageBox.Show("导入失败", "提示");
}
}
}