GDAL(Geospatial Data Abstraction Library)??????????,????????????C#???GDAL?,?????????NuGet?,??????????????????????????,?????C#???GDAL?????????????
-
??,???????GDAL??????????(https://gdal.org/)????????Windows??,????????????????:https://www.gisinternals.com/query.html?content=filelist&file=release/2021/2109/vc16/x64/gdal/
-
??C#?GDAL NuGet???Visual Studio?,??"??">"NuGet????">"???????NuGet?",???????
GDAL
?GDAL.Native
?? -
?C#?????GDAL?,??????????????????,??????GeoTIFF?????????:
using System;
using OSGeo.GDAL;
namespace GdalExample
{
class Program
{
static void Main(string[] args)
{
// ??GDAL????
Gdal.AllRegister();
// ??GeoTIFF??
string inputFile = "path/to/your/geotiff/file.tif";
Dataset dataset = Gdal.Open(inputFile, Access.GA_ReadOnly);
if (dataset == null)
{
Console.WriteLine("Error: Unable to open the input file.");
return;
}
// ????????
int width = dataset.RasterXSize;
int height = dataset.RasterYSize;
int numBands = dataset.RasterCount;
Console.WriteLine($"Width: {width}, Height: {height}, Bands: {numBands}");
// ???????????
// ...
// ????
dataset.Dispose();
}
}
}
???,????????????GeoTIFF???????????????????,???????????GDAL??????????????GDAL?????(https://gdal.org/user/index.html)???????????