管道基础大数据平台系统开发-【CS】-ExportMap
34
13693261870
2024-07-20 c1ac20e223474eef374094107704f037f7218a19
34
已修改1个文件
28 ■■■■■ 文件已修改
SimuTools/Tools/Handle.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SimuTools/Tools/Handle.cs
@@ -93,6 +93,7 @@
            {
                string tif = Path.Combine(tempPath, DateTime.Now.Ticks.ToString() + ".tif");
                Resample(ds.GetDescription(), tif, sizes[0], sizes[1]);
                //Resample(ds, tif, sizes[0], sizes[1]);
                if (!File.Exists(tif))
                {
                    continue;
@@ -447,20 +448,25 @@
        /// </summary>
        private static void Resample(Dataset ds, string dest, int width, int height)
        {
            // 设置Warp的选项:https://blog.csdn.net/qq_43210879/article/details/121350561
            string[] options = new string[] {
                "format=GTiff",
                "width=" + width,
                "height=" + height,
                "dstSRS=EPSG:4326"
            // https://blog.51cto.com/u_16099346/6691820
            //string args = string.Format("-t_srs {0} -ts {1} {2} -r {3} -of {4}", "EPSG:4326", width, height, "bilinear", "GTiff");
            //string[] options = Gdal.ParseCommandLine(args);
            string[] options = new string[]
            {
                "-t_srs",
                "EPSG:4326",
                "-ts",
                width.ToString(),
                height.ToString(),
                "-r",
                "bilinear",
                "-of",
                "GTiff"
            };
            OSGeo.GDAL.Driver driver = Gdal.GetDriverByName("GTiff");
            Dataset destDs = driver.Create(dest, width, height, ds.RasterCount, ds.GetRasterBand(1).DataType, null);
            GDALWarpAppOptions warpAppOptions = new GDALWarpAppOptions(options);
            Gdal.Warp(destDs, new Dataset[] { ds }, warpAppOptions, null, null);
            Dataset destDs = Gdal.Warp(dest, new Dataset[] { ds }, warpAppOptions, null, null);
            destDs.Dispose();
        }
        #endregion