Implementation of the GDAL v2 librified functions. Not all functions are implemented yet.
More...
|
bool | ClipVectorWithVector (string subjectFilename, string overlayFilename, string destinationFilename, bool useSharedConnection=true) |
| Clips the vector with another vector. More...
|
|
string | ErrorMsg (int errorCode) |
| Retrieves the error message associated with the specified error code. More...
|
|
bool | GdalBuildOverviews (string sourceFilename, tkGDALResamplingMethod resamplingMethod, int[] overviewList, int[] bandList, string[] configOptions) |
| Build raster overview(s) Implementing the librified function of GDAL's gdaladdo.exe tool More...
|
|
bool | GdalRasterTranslate (string sourceFilename, string destinationFilename, string[] options) |
| Converts raster data between different formats. Implementing the librified function of GDAL's gdal_translate.exe tool More...
|
|
bool | GdalRasterWarp (string sourceFilename, string destinationFilename, string[] options) |
| Image reprojection and warping utility. Implementing the librified function of GDAL's gdalwarp.exe tool More...
|
|
bool | GdalVectorReproject (string sourceFilename, string destinationFilename, int sourceEpsgCode, int destinationEpsgCode, bool useSharedConnection=false) |
| Helper file to simply reproject a file from an EPSG code to another EPSG code. Uses GdalVectorTranslate() internally. If you need more options use GdalVectorTranslate() instead. More...
|
|
bool | GdalVectorTranslate (string sourceFilename, string destinationFilename, string[] options, bool useSharedConnection=false) |
| Converts simple features data between file formats. Implementing the librified function of GDAL's ogr2ogr.exe tool More...
|
|
|
string | DetailedErrorMsg [get] |
| Gets the detailed error message. More...
|
|
ICallback | GlobalCallback [get, set] |
| The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications. More...
|
|
string | Key [get, set] |
| The key may be used by the programmer to store any string data associated with the object. More...
|
|
int | LastErrorCode [get] |
| Retrieves the last error generated in the object. More...
|
|
Implementation of the GDAL v2 librified functions. Not all functions are implemented yet.
- New API 4.9.5:
- Added in version 4.9.5
◆ ClipVectorWithVector()
bool GdalUtils.ClipVectorWithVector |
( |
string |
subjectFilename, |
|
|
string |
overlayFilename, |
|
|
string |
destinationFilename, |
|
|
bool |
useSharedConnection = true |
|
) |
| |
Clips the vector with another vector.
- Parameters
-
subjectFilename | The subject filename. |
overlayFilename | The overlay filename. |
destinationFilename | The destination filename. |
useSharedConnection | If set to true improves performance but also might make it instable. |
Uses GdalUtils.GdalVectorTranslate under the hood.
- New API 4.9.5:
- Added in version 4.9.5
var outputFilename = Path.Combine(tempFolder, "GdalVectorTranslate.shp");
if (!gdalUtils.ClipVectorWithVector("LargeFile.shp", "Border.shp", outputFilename))
{
Debug.WriteLine("GdalVectorTranslate failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
Implementation of the GDAL v2 librified functions. Not all functions are implemented yet.
Definition: GdalUtils.cs:26
◆ ErrorMsg()
string GdalUtils.ErrorMsg |
( |
int |
errorCode | ) |
|
Retrieves the error message associated with the specified error code.
- Parameters
-
errorCode | The error code for which the error message is required. |
- Returns
- The error message description for the specified error code.
- New API 4.9.5:
- Added in version 4.9.5
Debug.WriteLine(gdalUtils.ErrorMsg[gdalUtils.LastErrorCode]);
◆ GdalBuildOverviews()
bool GdalUtils.GdalBuildOverviews |
( |
string |
sourceFilename, |
|
|
tkGDALResamplingMethod |
resamplingMethod, |
|
|
int[] |
overviewList, |
|
|
int[] |
bandList, |
|
|
string[] |
configOptions |
|
) |
| |
Build raster overview(s) Implementing the librified function of GDAL's gdaladdo.exe
tool
- Parameters
-
sourceFilename | The source filename |
resamplingMethod | Controlling the downsampling method applied, defaults to grmNearest |
overviewList | A list of integral overview levels to build, as an integer array |
bandList | List of band numbers, band numbering starts from 1, as an integer array |
configOptions | The configuration options, as a string array (- -config ) |
See GDAL's documentation here: https://gdal.org/programs/gdaladdo.html A good guide about compressions of GeoTiff: https://kokoalberti.com/articles/geotiff-compression-optimization-guide/
- New API 5.1:
- Added in version 5.1.0
var configOptions = new[] { "COMPRESS_OVERVIEW DEFLATE", "INTERLEAVE_OVERVIEW PIXEL" };
if (!gdalUtils.GdalBuildOverviews("test.tif, tkGDALResamplingMethod.grmCubic, null, null, configOptions);)
{
Debug.WriteLine("GdalBuildOverviews failed:
" + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error:
" + gdalUtils.DetailedErrorMsg);
}
bool GdalBuildOverviews(string sourceFilename, tkGDALResamplingMethod resamplingMethod, int[] overviewList, int[] bandList, string[] configOptions)
Build raster overview(s) Implementing the librified function of GDAL's gdaladdo.exe tool
Definition: GdalUtils.cs:153
var configOptions = new[] { "COMPRESS_OVERVIEW JPEG", "PHOTOMETRIC_OVERVIEW YCBCR", "INTERLEAVE_OVERVIEW PIXEL" };
var overviewList = new[] { 2, 4, 8, 16, 32, 64, 128 };
var bandList = new[] { 1, 2, 3 };
if (!gdalUtils.GdalBuildOverviews(
"test.tif",
tkGDALResamplingMethod.grmAverage, overviewList, bandList, configOptions);)
{
Debug.WriteLine("GdalBuildOverviews failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
tkGDALResamplingMethod
The resampling mode which is used for building GDAL overviews, controlling the downsampling method ap...
Definition: Enumerations.cs:549
◆ GdalRasterTranslate()
bool GdalUtils.GdalRasterTranslate |
( |
string |
sourceFilename, |
|
|
string |
destinationFilename, |
|
|
string[] |
options |
|
) |
| |
Converts raster data between different formats. Implementing the librified function of GDAL's gdal_translate.exe
tool
- Parameters
-
sourceFilename | The source filename. |
destinationFilename | The destination filename. |
options | The options, as a string array |
See GDAL's documentation here: https://gdal.org/programs/gdal_translate.html
- New API 5.1:
- Added in version 5.1.0
var output = Path.GetTempPath() + "ChangedResolution.tif";
var options = new[]
{
"-ot", "Float32",
"-tr", "0.2", "0.2",
"-r", "average",
"-projwin", "-180", "90", "180", "-90"
};
if (!gdalUtils.GdalRasterTranslate("test.tif", output, options))
{
Debug.WriteLine("GdalRasterTranslate failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
◆ GdalRasterWarp()
bool GdalUtils.GdalRasterWarp |
( |
string |
sourceFilename, |
|
|
string |
destinationFilename, |
|
|
string[] |
options |
|
) |
| |
Image reprojection and warping utility. Implementing the librified function of GDAL's gdalwarp.exe
tool
- Parameters
-
sourceFilename | The source filename. |
destinationFilename | The destination filename. |
options | The options, as a string array |
See GDAL's documentation here: https://gdal.org/programs/gdalwarp.html
- New API 4.9.5:
- Added in version 4.9.5
- New API 5.1:
- Renamed from GdalWarp in version 5.1.0
var output = Path.GetTempPath() + "GdalWarp.vrt";
var options = new[]
{
"-of", "vrt",
"-overwrite"
};
if (!gdalUtils.GdalRasterWarp("test.tif", output, options))
{
Debug.WriteLine("GdalRasterWarp failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
var output = Path.GetTempPath() + "GdalWarpCutline.vrt";
const string border = @"test.shp";
var options = new[]
{
"-of", "vrt",
"-overwrite",
"-crop_to_cutline",
"-cutline", border
};
if (!gdalUtils.GdalRasterWarp("test.tif", output, options))
{
Debug.WriteLine("GdalRasterWarp failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
◆ GdalVectorReproject()
bool GdalUtils.GdalVectorReproject |
( |
string |
sourceFilename, |
|
|
string |
destinationFilename, |
|
|
int |
sourceEpsgCode, |
|
|
int |
destinationEpsgCode, |
|
|
bool |
useSharedConnection = false |
|
) |
| |
Helper file to simply reproject a file from an EPSG code to another EPSG code. Uses GdalVectorTranslate() internally. If you need more options use GdalVectorTranslate() instead.
- Parameters
-
sourceFilename | The source filename. |
destinationFilename | The destination filename. |
sourceEpsgCode | The source EPSG code. |
destinationEpsgCode | The destination EPSG code. |
useSharedConnection | If set to true improves performance but also might make it instable. |
- New API 5.4:
- Added in version 5.4
var outputFilename = Path.Combine(Path.GetTempPath(), "translated.shp");
if (!gdalUtils.GdalVectorReproject(sourceFilename, outputFilename, 4326, 28992))
{
Debug.WriteLine("GdalVectorReproject failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
◆ GdalVectorTranslate()
bool GdalUtils.GdalVectorTranslate |
( |
string |
sourceFilename, |
|
|
string |
destinationFilename, |
|
|
string[] |
options, |
|
|
bool |
useSharedConnection = false |
|
) |
| |
Converts simple features data between file formats. Implementing the librified function of GDAL's ogr2ogr.exe
tool
- Parameters
-
sourceFilename | The source filename. |
destinationFilename | The destination filename. |
options | The options, as a string array |
useSharedConnection | If set to true improves performance but also might make it instable. |
See GDAL's documentation here: https://gdal.org/programs/ogr2ogr.html
- New API 4.9.5:
- Added in version 4.9.5
var outputFilename = Path.Combine(Path.GetTempPath(), "translated.gml");
var options = new[]
{
"-f", "GML"
};
if (!gdalUtils.GdalVectorTranslate(inputFilename, outputFilename, options, true))
{
Debug.WriteLine("GdalVectorTranslate failed: " + gdalUtils.ErrorMsg[gdalUtils.LastErrorCode] + " Detailed error: " + gdalUtils.DetailedErrorMsg);
}
◆ DetailedErrorMsg
string GdalUtils.DetailedErrorMsg |
|
get |
Gets the detailed error message.
- New API 4.9.5:
- Added in version 4.9.5
Debug.WriteLine(gdalUtils.DetailedErrorMsg);
◆ GlobalCallback
The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.
- New API 4.9.5:
- Added in version 4.9.5
◆ Key
The key may be used by the programmer to store any string data associated with the object.
- New API 4.9.5:
- Added in version 4.9.5
◆ LastErrorCode
int GdalUtils.LastErrorCode |
|
get |
Retrieves the last error generated in the object.
- New API 4.9.5:
- Added in version 4.9.5
Debug.WriteLine(gdalUtils.ErrorMsg[gdalUtils.LastErrorCode]);