第一步:创建镶嵌数据集,并且添加影像到数据集;
DatasetMosaic datasetMosaic = datasource.Datasets.CreateMosaic(datasource.Datasets.GetAvailableDatasetName(filename), prj);
datasetMosaic.AddFiles(new string[1] { filepath });
第二步,构建概视图:
datasetMosaic.BuildOverview(datasetMosaicOverviewPath, 5120, 5120, 3, true, 0);
第三步:添加镶嵌数据集到地图:
DatasetMosaic dataset = datasource.Datasets[i] as DatasetMosaic;
LayerMosaicGroup layerMosaicGroup = mapControl.Map.Layers.AddMosaicGroup(dataset, true);
LayerMosaic layerMosaic = layerMosaicGroup.MosaicLayer;
LayerSettingImage layersetting = layerMosaic.SettingImage as LayerSettingImage;
layersetting.DisplayBandIndexes = new int[3] { 2, 1, 0 };
layersetting.DisplayMode = ImageDisplayMode.Composite;
layersetting.DisplayColorSpace = ColorSpaceType.RGB;
layersetting.ImageInterpolationMode = ImageInterpolationMode.NearestNeighbor;
dataset.BuildStatistics();
ImageStretchOption option = new ImageStretchOption();
option.StretchType = ImageStretchType.StandardDeviation;
option.StandardDeviationStretchFactor = 2;
layersetting.ImageStretchOption = option;
layersetting.BackgroundColor = Color.FromArgb(0, 0, 0);
//layersetting.SpecialValueColor = Color.FromArgb(65535, 65535, 55537);
//layersetting.IsSpecialValueTransparent = true;
layersetting.IsBackgroundTransparent = true;
layerMosaicGroup.FootprintLayer.IsVisible = false;
layerMosaicGroup.BoundaryLayer.IsVisible = false;
layerMosaicGroup[1].IsVisible=false;