public void SaveAsTest() { string gridDataFolder = Common.AbsolutePath(@"Data\Grids\"); var p = new GdalRasterProvider(); var sourceGrid = p.Open(Path.Combine(gridDataFolder, @"elev_cm_ESRI\elev_cm_clip2\hdr.adf")); var sourceGridMaximum = sourceGrid.Maximum; string savedGridName = Path.Combine(gridDataFolder, @"elev_cm.tif"); sourceGrid.SaveAs(savedGridName); Assert.AreEqual(sourceGrid.Maximum, sourceGridMaximum, 0.0001); var savedSourceGrid = Raster.Open(savedGridName); Assert.AreEqual(sourceGridMaximum, savedSourceGrid.Maximum, 0.0001); sourceGrid.Close(); savedSourceGrid.Close(); File.Delete(savedGridName); }
public void SaveAsTest() { const string GridDataFolder = @"Data\Grids\"; var p = new GdalRasterProvider(); var sourceGrid = p.Open(GridDataFolder + @"elev_cm_ESRI\elev_cm_clip2\hdr.adf"); var sourceGridMaximum = sourceGrid.Maximum; const string SavedGridName = GridDataFolder + @"elev_cm.tif"; sourceGrid.SaveAs(SavedGridName); Assert.AreEqual(sourceGrid.Maximum, sourceGridMaximum, 0.0001); var savedSourceGrid = Raster.Open(SavedGridName); Assert.AreEqual(sourceGridMaximum, savedSourceGrid.Maximum, 0.0001); sourceGrid.Close(); savedSourceGrid.Close(); File.Delete(SavedGridName); }
static void Main(string[] args) { SetDllDirectory(@"D:\DotSpatial-master\Source\bin\Debug\Windows Extensions\DotSpatial.Data.Rasters.GdalExtension\gdal\x86"); string loadfilepath = @"D:\test.tif"; // GeoTiff読み込み GdalRasterProvider d = new GdalRasterProvider(); IRaster src = d.Open(loadfilepath); int ncol = src.NumColumns; int nrow = src.NumRows; int band_num = src.NumBands; string prj = src.ProjectionString; double nodata = src.NoDataValue; double[] pGT = src.Bounds.AffineCoefficients; double xllcenter = pGT[0]; // コーナーではないので注意 double cellsize_x = pGT[1]; double rotate1 = pGT[2]; double yllcenter = pGT[3]; // コーナーではないので注意 double rotate2 = pGT[4]; double cellsize_y = pGT[5]; Console.WriteLine("H11 = " + src.Value[0, 0]); Console.WriteLine("H12 = " + src.Value[0, 1]); Console.WriteLine("H13 = " + src.Value[0, 2]); Console.WriteLine("H21 = " + src.Value[1, 0]); Console.WriteLine("H22 = " + src.Value[1, 1]); Console.WriteLine("H23 = " + src.Value[1, 2]); Console.WriteLine("H31 = " + src.Value[2, 0]); Console.WriteLine("H32 = " + src.Value[2, 1]); Console.WriteLine("H33 = " + src.Value[2, 2]); Console.ReadKey(); return; }