A utils object provides access to a set of utility functions to perform a variety of tasks on other objects such as grids, images, points, shapes, shapefiles, tins, etc.
Starting at v4.9.5 some specific GDAL methods are moved to GdalUtils.
More...
Public Member Functions | |
bool | BufferByDistance (Shapefile subject, double Distance, int nSegments, bool SelectedOnly, bool MergeResults, string outputFilename, bool Overwrite) |
bool | CalculateRaster (Array filenames, string Expression, string outputFilename, string gdalOutputFormat, float NodataValue, ICallback cBack, out string ErrorMsg) |
Creates a new raster dataset based on the array of input datasets and an arbitrary formula to calculate values of output dataset. More... | |
bool | ClipGridWithPolygon (string inputGridfile, Shape poly, string resultGridfile, bool keepExtents) |
Creates a new grid from the input one in which all values outside the specified polygon are set to no data value. More... | |
bool | ClipGridWithPolygon2 (Grid inputGrid, Shape poly, string resultGridfile, bool keepExtents) |
Creates a new grid from the input one in which all values outside the specified polygon are set to no data value. More... | |
Shape | ClipPolygon (PolygonOperation op, Shape SubjectPolygon, Shape ClipPolygon) |
Modifies a polygon using the specified method. More... | |
uint | ColorByName (tkMapColor Name) |
Returns the numeric representation for the specified color. More... | |
bool | ConvertDistance (tkUnitsOfMeasure sourceUnit, tkUnitsOfMeasure targetUnit, ref double Value) |
Converts distance from one units of measuring to another. More... | |
bool | CopyNodataValues (string sourceFilename, string destFilename) |
Copies no data values from one grid datasource to another. More... | |
object | CreateInstance (tkInterface interfaceId) |
Creates an instance of specified COM CoClass implementing specified interface. More... | |
tkUnitsOfMeasure | EPSGUnitConversion (int EPSGUnitCode) |
Gets the tkUnitsOfMeasure enumeration associated with the specified EPSG Unit Code More... | |
string | ErrorMsgFromObject (object comClass) |
Displays error message for the last error that took place within object passed as parameter. More... | |
bool | ExplodeShapes (Shapefile subject, bool SelectedOnly, string outputFilename, bool Overwrite) |
bool | ExportSelection (Shapefile subject, string outputFilename, bool Overwrite) |
bool | FixUpShapes (Shapefile subject, bool SelectedOnly, string outputFilename, bool Overwrite) |
bool | GDALAddOverviews (string bstrSrcFilename, string bstrOptions, string bstrLevels, ICallback cBack=null) |
The same as GDAL's gdaladdo.exe utility. More... | |
bool | GDALBuildVrt (string bstrDstFilename, string bstrOptions, ICallback cBack=null) |
The same as GDAL's gdalbuildvert.exe utility. More... | |
string | GDALInfo (string bstrSrcFilename, string bstrOptions, ICallback cBack=null) |
The same as GDAL's gdalinfo.exe utility. More... | |
bool | GDALRasterize (string bstrSrcFilename, string bstrDstFilename, string bstrOptions, ICallback cBack=null) |
The same as GDAL's gdal_rasterize.exe utility. More... | |
bool | GDALWarp (string bstrSrcFilename, string bstrDstFilename, string bstrOptions, ICallback cBack=null) |
The same as GDAL's gdalwarp.exe utility More... | |
bool | GenerateContour (string bstrSrcFilename, string bstrDstFilename, double dfInterval, double dfNoData, bool Is3D, object dblFLArray, ICallback cBack) |
This program generates a vector contour file from the input raster elevation model (DEM). More... | |
bool | GenerateHillShade (string bstrGridFilename, string bstrShadeFilename, float Z, float scale, float az, float alt) |
Generates a hillshade image for a raster data source. More... | |
double | GeodesicArea (Shape shapeWgs84) |
double | GeodesicDistance (double lat1, double lng1, double lat2, double lng2) |
Calculates geodesic distance between 2 points on Earth. More... | |
double | get_Area (Shape Shape) |
Returns the area of the polygon shape. For multi-part polygons which may contain counter-clockwise holes, the area of the holes will be subtracted from that of the surrounding clockwise portions. More... | |
string | get_ComUsageReport (bool unreleasedOnly) |
Gets report about COM objects that were created and released. More... | |
string | get_ErrorMsg (int ErrorCode) |
Retrieves the error message associated with the specified error code. More... | |
double | get_Length (Shape Shape) |
Gets the length of the line shape. More... | |
double | get_Perimeter (Shape Shape) |
Gets the perimeter of the polygon shape. More... | |
double | GetAngle (Point firstPoint, Point secondPoint) |
Calculates the angle defined by the two specified coordinates More... | |
string | GetNAD83ProjectionName (tkNad83Projection projectionID) |
Gets the name of the projection associated with the specified NAD83 enumeration More... | |
bool | GetProjectionList (tkProjectionSet projectionSets, ref Object list) |
Gets a list of ID,Name pairs of Projected and/or Geographic coordinate systems More... | |
string | GetProjectionNameByID (int SRID) |
Gets the name of the projected coordinate system associated with the specified SRID, which include the NAD83 and WGS84 codes, as well as those not specified by the enumerations, such as NAD27, NAD83 Harn, Beijing, Pulkova, etc. More... | |
string | GetWGS84ProjectionName (tkWgs84Projection projectionID) |
Gets the name of the projection associated with the specified WGS84 enumeration More... | |
bool | GridInterpolateNoData (Grid Grd, ICallback cBack) |
Uses valid data in a grid to replace grid cells containing no-data values with an interpolated value. More... | |
Grid | GridMerge (object Grids, string MergeFilename, bool InRam, GridFileType GrdFileType, ICallback cBack) |
Merges multiple grids into a single output grid. More... | |
bool | GridReplace (Grid Grd, object OldValue, object newValue, ICallback cBack) |
Replaces all occurrences of a value in the grid with a new value. More... | |
bool | GridStatisticsForPolygon (Grid Grid, GridHeader Header, Extents gridExtents, Shape Shape, double NodataValue, ref double MeanValue, ref double MinValue, ref double MaxValue) |
Calculates statistics for portion of grid that is overlapped by specified polygon. More... | |
bool | GridStatisticsToShapefile (Grid Grid, Shapefile sf, bool SelectedOnly, bool overwriteFields, bool useCenterWithinMethod=true) |
Calculates statistics for grid cells within each polygon of the specified shapefile. Writes results to attribute table of shapefile. More... | |
Grid | GridToGrid (Grid Grid, GridDataType OutDataType, ICallback cBack) |
Creates a new grid of the same size as the original grid, converting the values of the original grid into a different data type in the new grid. More... | |
Image | GridToImage (Grid Grid, GridColorScheme cScheme, ICallback cBack) |
Creates an image from the grid using the given grid color scheme. More... | |
Image | GridToImage2 (Grid Grid, GridColorScheme ci, tkGridProxyFormat imageFormat, bool InRam, ICallback cBack) |
Creates an image proxy for grid visualization. More... | |
Shapefile | GridToShapefile (Grid Grid, Grid ConnectionGrid, ICallback cBack) |
Creates a new shapefile from the grid. Note: It is important that the flow grid is used when there are any ambiguous parts of the grid. More... | |
stdole.IPictureDisp | hBitmapToPicture (int hBitmap) |
Converts an hBitmap to an IPictureDisp object. More... | |
bool | IsTiffGrid (string Filename) |
Returns a boolean value which indicates whether the specified file holds tiff grid. More... | |
Point | LineInterpolatePoint (Shape sourceLine, Point startPoint, double distance, bool normalized) |
Return a point at the specified distance (or percentage) along the specified line More... | |
bool | MaskRaster (string Filename, byte newPerBandValue) |
Sets all the values inside datasource, which aren't equal to no data value, to a new value. More... | |
bool | MergeImages (Array InputNames, string OutputName) |
Merges several images in a single image. More... | |
bool | OGR2OGR (string bstrSrcFilename, string bstrDstFilename, string bstrOptions, ICallback cBack=null) |
The same as GDAL's ogr2ogr utility. More... | |
string | OGRInfo (string bstrSrcFilename, string bstrOptions, string bstrLayers=null, ICallback cBack=null) |
The same as GDAL's OGRInfo utility. More... | |
Shapefile | OGRLayerToShapefile (string Filename, ShpfileType ShpType, ICallback cBack) |
Partially implemented. Creates a shapefile from any vector format supported by OGR library. More... | |
bool | PointInPolygon (Shape Shp, Point TestPoint) |
Gets whether or not a point lies within the specified polygon shape. More... | |
bool | Polygonize (string pszSrcFilename, string pszDstFilename, int iSrcBand=1, bool NoMask=false, string pszMaskFilename="0", string pszOGRFormat="GML", string pszDstLayerName="out", string pszPixValFieldName="DN", ICallback cBack=null) |
The same as GDAL's gdal_polygonize utility. More... | |
Double | ProjectDistanceTo (Shape sourceLine, Shape referenceShape) |
Return a distance along the source polyline to a Point nearest the reference Shape More... | |
bool | ReclassifyRaster (string Filename, int bandIndex, string OutputName, Array LowerBounds, Array UpperBounds, Array NewValues, string gdalOutputFormat, ICallback cBack) |
Creates a new datasource by mapping data ranges of the specified band of input datasource to new values. More... | |
bool | RemoveColinearPoints (Shapefile Shapes, double LinearTolerance, ICallback cBack) |
Removes colinear points from a shapefile. More... | |
Shapefile | ReprojectShapefile (Shapefile sf, GeoProjection source, GeoProjection target) |
Reprojects a shapefile. More... | |
Grid | ShapefileToGrid (Shapefile Shpfile, bool UseShapefileBounds, GridHeader GrdHeader, double Cellsize, bool UseShapeNumber, short SingleValue) |
This function is not implemented. Converts a shapefile to a grid. More... | |
Shape | ShapeMerge (Shapefile Shapes, int IndexOne, int IndexTwo, ICallback cBack) |
Merges two shapes in a shapefile to create a new shape. More... | |
Shapefile | ShapeToShapeZ (Shapefile Shapefile, Grid Grid, ICallback cBack) |
Creates a new shapefile with z values added from an elevation grid. More... | |
GeoProjection | TileProjectionToGeoProjection (tkTileProjection Projection) |
Initializes GeoProjection object with projection used by specific tile service. More... | |
Shapefile | TinToShapefile (Tin Tin, ShpfileType Type, ICallback cBack) |
Creates a shapefile from a TIN object. More... | |
bool | TranslateRaster (string bstrSrcFilename, string bstrDstFilename, string bstrOptions, ICallback cBack) |
Converts raster data between different formats, potentially performing some operations like subsettings, resampling, and rescaling pixels in the process. More... | |
Properties | |
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... | |
A utils object provides access to a set of utility functions to perform a variety of tasks on other objects such as grids, images, points, shapes, shapefiles, tins, etc.
Starting at v4.9.5 some specific GDAL methods are moved to GdalUtils.
bool Utils.BufferByDistance | ( | Shapefile | subject, |
double | Distance, | ||
int | nSegments, | ||
bool | SelectedOnly, | ||
bool | MergeResults, | ||
string | outputFilename, | ||
bool | Overwrite | ||
) |
bool Utils.CalculateRaster | ( | Array | filenames, |
string | Expression, | ||
string | outputFilename, | ||
string | gdalOutputFormat, | ||
float | NodataValue, | ||
ICallback | cBack, | ||
out string | ErrorMsg | ||
) |
Creates a new raster dataset based on the array of input datasets and an arbitrary formula to calculate values of output dataset.
filenames | Array of filenames. |
Expression | Formula to calculate. |
outputFilename | Name of output dataset. |
gdalOutputFormat | GDAL format. See list here: http://www.gdal.org/formats_list.html. Not all of them are necessarily support creation and writing operations. |
NodataValue | No data value for output datasource. |
cBack | Callback to report progress and errors. |
ErrorMsg | Error description to be returned when method fails. |
Input datasets must have the same size in pixels (projection and transformation parameters will be copied to output from first datasource, but won't be used during calculation process). Names of datasources in formula must match their filenames without path. Additionally @X postfix must be added to mark index of band to be used (1-based). The following operation are supported in formula: arithmetic (+, -, *, /, ^); comparisons (>, <, <=, >=, <>, =) both for raster values and scalar constants.
bool Utils.ClipGridWithPolygon | ( | string | inputGridfile, |
Shape | poly, | ||
string | resultGridfile, | ||
bool | keepExtents | ||
) |
Creates a new grid from the input one in which all values outside the specified polygon are set to no data value.
inputGridfile | Filename of input grid. |
poly | Clipping polygon. |
resultGridfile | Filename of the results grid. |
keepExtents | True in case grid must not be clipped using polygon extents. |
bool Utils.ClipGridWithPolygon2 | ( | Grid | inputGrid, |
Shape | poly, | ||
string | resultGridfile, | ||
bool | keepExtents | ||
) |
Creates a new grid from the input one in which all values outside the specified polygon are set to no data value.
inputGrid | INput grid. |
poly | Clipping polygon. |
resultGridfile | Filename of the results grid. |
keepExtents | True in case grid must not be clipped using polygon extents. |
Shape Utils.ClipPolygon | ( | PolygonOperation | op, |
Shape | SubjectPolygon, | ||
Shape | ClipPolygon | ||
) |
Modifies a polygon using the specified method.
op | The operation to use on the subject polygon. |
SubjectPolygon | The first polygon to perform the specified polygon operation on. |
ClipPolygon | The second polygon to perform the specified polygon operation with. |
uint Utils.ColorByName | ( | tkMapColor | Name | ) |
Returns the numeric representation for the specified color.
The return value can be used for all properties which require color specification as unsigned integer.
Name | The name of the color. |
bool Utils.ConvertDistance | ( | tkUnitsOfMeasure | sourceUnit, |
tkUnitsOfMeasure | targetUnit, | ||
ref double | Value | ||
) |
Converts distance from one units of measuring to another.
sourceUnit | Source units of measuring. |
targetUnit | Target units of measuring. |
Value | The value in source units to be converted. |
bool Utils.CopyNodataValues | ( | string | sourceFilename, |
string | destFilename | ||
) |
Copies no data values from one grid datasource to another.
sourceFilename | Filename of the source. |
destFilename | Filename of the target. |
Datasources must have the same size, number of bands, byte data type and must both be supported by GDAL.
object Utils.CreateInstance | ( | tkInterface | interfaceId | ) |
Creates an instance of specified COM CoClass implementing specified interface.
interfaceId | Interface to be created. |
This method might be slightly faster than direct object creation when mass creation of objects is needed./remarks>
tkUnitsOfMeasure Utils.EPSGUnitConversion | ( | int | EPSGUnitCode | ) |
Gets the tkUnitsOfMeasure enumeration associated with the specified EPSG Unit Code
EPSGUnitCode | EPSG-defined Unit of Measure constant |
Supports the more common EPSG-defined Unit constants; specifically those that can be mapped to the currently defined tkUnitsOfMeasure enumeration values. If the EPSG code cannot be mapped, an Error will be submitted to the global callback with error code tkINVALID_PARAMETER_VALUE, and return the default value of umDecimalDegrees.
string Utils.ErrorMsgFromObject | ( | object | comClass | ) |
Displays error message for the last error that took place within object passed as parameter.
comClass | Any MapWinGIS COM class which has LastErrorCode and get_ErrorMsg properties. |
The methods is alternative syntax of calling:
Now it also can be done like:
bool Utils.ExplodeShapes | ( | Shapefile | subject, |
bool | SelectedOnly, | ||
string | outputFilename, | ||
bool | Overwrite | ||
) |
bool Utils.ExportSelection | ( | Shapefile | subject, |
string | outputFilename, | ||
bool | Overwrite | ||
) |
bool Utils.FixUpShapes | ( | Shapefile | subject, |
bool | SelectedOnly, | ||
string | outputFilename, | ||
bool | Overwrite | ||
) |
bool Utils.GDALAddOverviews | ( | string | bstrSrcFilename, |
string | bstrOptions, | ||
string | bstrLevels, | ||
ICallback | cBack = null |
||
) |
The same as GDAL's gdaladdo.exe utility.
See documentation here: http://www.gdal.org/gdaladdo.html
bool Utils.GDALBuildVrt | ( | string | bstrDstFilename, |
string | bstrOptions, | ||
ICallback | cBack = null |
||
) |
The same as GDAL's gdalbuildvert.exe utility.
See documentation here: http://www.gdal.org/gdalbuildvert.html
string Utils.GDALInfo | ( | string | bstrSrcFilename, |
string | bstrOptions, | ||
ICallback | cBack = null |
||
) |
The same as GDAL's gdalinfo.exe utility.
See documentation here: http://www.gdal.org/gdalinfo.html
bool Utils.GDALRasterize | ( | string | bstrSrcFilename, |
string | bstrDstFilename, | ||
string | bstrOptions, | ||
ICallback | cBack = null |
||
) |
The same as GDAL's gdal_rasterize.exe utility.
See documentation here: http://www.gdal.org/gdal_rasterize.html
bool Utils.GDALWarp | ( | string | bstrSrcFilename, |
string | bstrDstFilename, | ||
string | bstrOptions, | ||
ICallback | cBack = null |
||
) |
The same as GDAL's gdalwarp.exe utility
See documentation here: http://www.gdal.org/gdalwarp.html
bool Utils.GenerateContour | ( | string | bstrSrcFilename, |
string | bstrDstFilename, | ||
double | dfInterval, | ||
double | dfNoData, | ||
bool | Is3D, | ||
object | dblFLArray, | ||
ICallback | cBack | ||
) |
This program generates a vector contour file from the input raster elevation model (DEM).
See documentation here: http://www.gdal.org/gdal_contour.html
bool Utils.GenerateHillShade | ( | string | bstrGridFilename, |
string | bstrShadeFilename, | ||
float | Z, | ||
float | scale, | ||
float | az, | ||
float | alt | ||
) |
Generates a hillshade image for a raster data source.
This code was written by Matt Perry, perry.nosp@m.geo@.nosp@m.gmail.nosp@m..com, published in Gdal-dev Digest, Vol 19, Issue 20 Note: Scale for Feet/Latlong use scale=370400, for Meters/LatLong use scale=111120 (based on the GRASS GIS algorithm from r.shaded.relief)
bstrGridFilename | The input raster data. This can be in virtually any raster data format. |
bstrShadeFilename | The output image filename. This can be virtually any image format, the extension will determine the format. |
Z | Z Factor. Defaults to 1. |
scale | Scale Factor. Defaults to 1. |
az | Azimuth. Defaults to 315. |
alt | Altitude. Defaults to 45. |
double Utils.GeodesicArea | ( | Shape | shapeWgs84 | ) |
double Utils.GeodesicDistance | ( | double | lat1, |
double | lng1, | ||
double | lat2, | ||
double | lng2 | ||
) |
Calculates geodesic distance between 2 points on Earth.
lat1 | Latitude of the first point in decimal degrees. |
lng1 | Longitude of the first point in decimal degrees. |
lat2 | Latitude of the second point in decimal degrees. |
lng2 | Longitude of the second point in decimal degrees. |
double Utils.get_Area | ( | Shape | Shape | ) |
Returns the area of the polygon shape. For multi-part polygons which may contain counter-clockwise holes, the area of the holes will be subtracted from that of the surrounding clockwise portions.
Shape | The polygon shape for which the area is required. |
string Utils.get_ComUsageReport | ( | bool | unreleasedOnly | ) |
Gets report about COM objects that were created and released.
unreleasedOnly | Indicates whether report must include information about already released objects. |
This method can be used to find memory leaking in MapWinGIS native code (forgotten object->Release call). The most vulnerable spots are geoprocessing functions, where thousands of Shape or Point objects may be created in a single API call. Before calling this make sure that:
string Utils.get_ErrorMsg | ( | int | ErrorCode | ) |
Retrieves the error message associated with the specified error code.
ErrorCode | The error code for which the error message is required. |
double Utils.get_Perimeter | ( | Shape | Shape | ) |
Gets the perimeter of the polygon shape.
Shape | The polygon shape for which the perimeter is required. |
Calculates the angle defined by the two specified coordinates
firstPoint | |
secondPoint |
The angle returned is the so-called Geographic angle, measured in a clockwise direction from the positive Y-axis, as opposed to the Arithmetic (Cartesian) angle measured in a counter-clockwise direction from the positive X-axis. The returned value can be used as-is to specify Shape or Label Rotation, which expect the Geographic angle for input.
string Utils.GetNAD83ProjectionName | ( | tkNad83Projection | projectionID | ) |
Gets the name of the projection associated with the specified NAD83 enumeration
projectionID | Value from the the NAD83 projection enumeration tkNad83Projection |
If an error occurs, either because an invalid ID is specified, or the projection string could not be loaded, a descriptive error will be raised to the Callback function (if one is specified).
bool Utils.GetProjectionList | ( | tkProjectionSet | projectionSets, |
ref Object | list | ||
) |
Gets a list of ID,Name pairs of Projected and/or Geographic coordinate systems
projectionSets | One or a combination of values from the tkProjectionSet enumeration |
list | Reference to an Object that will be filled with an array of strings |
Each string will contain one pair of values, an ID and a Name, separated by a comma (e.g. "32611,WGS 84 / UTM zone 11N"). These can be parsed and used, for example, to populate a ComboBox control for user selection of a Projection. If an error occurs, or if the projection strings could not be loaded, a descriptive error will be raised to the Callback function (if one is specified).
string Utils.GetProjectionNameByID | ( | int | SRID | ) |
Gets the name of the projected coordinate system associated with the specified SRID, which include the NAD83 and WGS84 codes, as well as those not specified by the enumerations, such as NAD27, NAD83 Harn, Beijing, Pulkova, etc.
SRID | Spatial Reference identifier, could refer to any valid Projected or Geographic coordinate system |
If an error occurs, either because an invalid ID is specified, or the projection string could not be loaded, a descriptive error will be raised to the Callback function (if one is specified).
string Utils.GetWGS84ProjectionName | ( | tkWgs84Projection | projectionID | ) |
Gets the name of the projection associated with the specified WGS84 enumeration
projectionID | Value from the the NAD83 projection enumeration tkNad83Projection |
If an error occurs, either because an invalid ID is specified, or the projection string could not be loaded, a descriptive error will be raised to the Callback function (if one is specified).
Uses valid data in a grid to replace grid cells containing no-data values with an interpolated value.
Grd | The grid for which no-data cells will be replaced with interpolated values. |
cBack | The ICallback object which will receive progress and error messages. |
Grid Utils.GridMerge | ( | object | Grids, |
string | MergeFilename, | ||
bool | InRam, | ||
GridFileType | GrdFileType, | ||
ICallback | cBack | ||
) |
Merges multiple grids into a single output grid.
Grids | An array of grid objects to be merged into one grid. |
MergeFilename | The filename to use for the new merged grid. |
InRam | Optional. A boolean value representing whether to create the merged grid in RAM or on disk |
GrdFileType | Optional. The file type of the new merged grid. |
cBack | Optional. The ICallback object which will receive progress and error messages while the grids are being merged. |
Replaces all occurrences of a value in the grid with a new value.
Grd | The grid to replace the specified value in. |
OldValue | The value in the grid to be replaced with the new value. |
newValue | The value to replace the old values with. |
cBack | The ICallback object which will receive progress and error mesages while the old value is being replaced with the new values in the grid. |
bool Utils.GridStatisticsForPolygon | ( | Grid | Grid, |
GridHeader | Header, | ||
Extents | gridExtents, | ||
Shape | Shape, | ||
double | NodataValue, | ||
ref double | MeanValue, | ||
ref double | MinValue, | ||
ref double | MaxValue | ||
) |
Calculates statistics for portion of grid that is overlapped by specified polygon.
Grid | Input grid |
Header | Grid header. Can be retrieved with Grid.Header property. |
gridExtents | Grid extents. Can be retrieved with Grid.Extents property. |
Shape | Polygon shape within borders of which the statistics will be calculated. |
NodataValue | No data value for grid. Can be retrieved from header. |
MeanValue | Calculated mean value. |
MinValue | Calculated min value. |
MaxValue | Calculated max value |
Header, gridExtents, NodataValue parameters are added, so that these properties can be retrieved only ones in case the function is called multiple times for each polygon in shapefile.
bool Utils.GridStatisticsToShapefile | ( | Grid | Grid, |
Shapefile | sf, | ||
bool | SelectedOnly, | ||
bool | overwriteFields, | ||
bool | useCenterWithinMethod = true |
||
) |
Calculates statistics for grid cells within each polygon of the specified shapefile. Writes results to attribute table of shapefile.
Grid | Input grid. |
sf | Polygon shapefile. |
SelectedOnly | A value indicating whether calculation will be made for selected polygons only. When set to false, calculation will be made for all polygons in shapefile. |
overwriteFields | If true output fields will be overwritten (if the fields with such names already exist). Otherwise new set of output fields will be created with numerical indices added to their names. |
useCenterWithinMethod | If true (default) the center of the pixel needs to be inside the polygon. If set to false Intersection method is used meaning each pixel boundary that intersects with the polygon is used. Added in v4.9.4.3. |
The default names for output fields: "Mean", "Median", "Majority", "Minority", "Minimum", "Maximum", "Range", "StD", "Sum", "MinX", "MinY", "Variety", "Count"
Grid Utils.GridToGrid | ( | Grid | Grid, |
GridDataType | OutDataType, | ||
ICallback | cBack | ||
) |
Creates a new grid of the same size as the original grid, converting the values of the original grid into a different data type in the new grid.
Grid | The original grid. |
OutDataType | The data type to convert the original grid values to for the new grid values. |
cBack | The ICallback object which will receive progress and error messages while the original grid values are converted and copied into the new grid. |
Image Utils.GridToImage | ( | Grid | Grid, |
GridColorScheme | cScheme, | ||
ICallback | cBack | ||
) |
Creates an image from the grid using the given grid color scheme.
Grid | The grid to use to create the image. |
cScheme | The grid color scheme to use to create an image from the grid. |
cBack | The ICallback object which will receive progress and error messages while the image is being created from the grid. |
Image Utils.GridToImage2 | ( | Grid | Grid, |
GridColorScheme | ci, | ||
tkGridProxyFormat | imageFormat, | ||
bool | InRam, | ||
ICallback | cBack | ||
) |
Creates an image proxy for grid visualization.
Grid | Grid to create proxy for. |
ci | Color scheme which defines the mapping of values to colors. |
imageFormat | The format of output image. |
InRam | True in case in-memory image should be created, otherwise it will saved to the drive. |
cBack | Callback interface. |
The filename of the resulting image (inRam = false) is set automatically: for example, grid.asc -> grid_proxy.bmp. In case of multi-band grids an image will be created for the active band, determined from Grid.ActiveBandIndex property. For bmp output format a world file will be written along with resulting file. For GTiff format the same values will be embedded in the file itself.
Creates a new shapefile from the grid. Note: It is important that the flow grid is used when there are any ambiguous parts of the grid.
Grid | The grid to be converted to a shapefile. |
ConnectionGrid | Optional. The flow grid that is used to resolve any ambiguity. Without this flow grid the output results are somewhat unpredictable. |
cBack | The ICallback object which will receive progress and error messages while the grid is being converted to the shapefile. |
stdole.IPictureDisp Utils.hBitmapToPicture | ( | int | hBitmap | ) |
Converts an hBitmap to an IPictureDisp object.
hBitmap | A device context handle to a bitmap. |
bool Utils.IsTiffGrid | ( | string | Filename | ) |
Returns a boolean value which indicates whether the specified file holds tiff grid.
Filename | The name of the file. |
Point Utils.LineInterpolatePoint | ( | Shape | sourceLine, |
Point | startPoint, | ||
double | distance, | ||
bool | normalized | ||
) |
Return a point at the specified distance (or percentage) along the specified line
sourceLine | Polyline shape to traverse |
startPoint | Starting point along 'sourceLine' (specify Point[0] for beginning of line) |
distance | Distance along line (or percentage of line length; if a percentage, specify a number between 0.0 and 1.0) |
normalized | Optional value; if FALSE, 'distance' is actual distance; if TRUE, distance is percentage of length; defaults to FALSE |
'sourceLine' must be a Polyline Shape. If 'distance' is greater than the source line length, the line's endpoint is returned.
'startPoint' does not have to be on 'sourceLine'. If not on the line, actual starting point will be the nearest point to 'startPoint' that is on 'sourceline'.
bool Utils.MaskRaster | ( | string | Filename, |
byte | newPerBandValue | ||
) |
Sets all the values inside datasource, which aren't equal to no data value, to a new value.
Filename | Filename of the input datasource. |
newPerBandValue | The new value set for all cells of each band which aren't equal to no data value. |
Datasource format must be supported by GDAL. Byte data type for values is expected.
bool Utils.MergeImages | ( | Array | InputNames, |
string | OutputName | ||
) |
Merges several images in a single image.
All the input images must be of the same size. The color marked in the input image as transparent won't be passed to the output.
InputNames | An array of string type with the filenames of the images. |
OutputName | The name if te output file. |
bool Utils.OGR2OGR | ( | string | bstrSrcFilename, |
string | bstrDstFilename, | ||
string | bstrOptions, | ||
ICallback | cBack = null |
||
) |
The same as GDAL's ogr2ogr utility.
See documentation here: http://www.gdal.org/ogr2ogr.html
string Utils.OGRInfo | ( | string | bstrSrcFilename, |
string | bstrOptions, | ||
string | bstrLayers = null , |
||
ICallback | cBack = null |
||
) |
The same as GDAL's OGRInfo utility.
See documentation here: http://www.gdal.org/ogrinfo.html
Shapefile Utils.OGRLayerToShapefile | ( | string | Filename, |
ShpfileType | ShpType, | ||
ICallback | cBack | ||
) |
Partially implemented. Creates a shapefile from any vector format supported by OGR library.
The method needs testing and elaboration to handle the peculiarities of various data formats.
Filename | The name of the vector data source. |
ShpType | The type of the output shapefile. |
cBack | The callback object to return information about progress and errors. |
Gets whether or not a point lies within the specified polygon shape.
There is a faster option available when working with shapefiles: PointInShape.
Shp | The polygon shape to perform the test on. |
TestPoint | The point to test whether or not it lies within the specified polygon shape. |
bool Utils.Polygonize | ( | string | pszSrcFilename, |
string | pszDstFilename, | ||
int | iSrcBand = 1 , |
||
bool | NoMask = false , |
||
string | pszMaskFilename = "0" , |
||
string | pszOGRFormat = "GML" , |
||
string | pszDstLayerName = "out" , |
||
string | pszPixValFieldName = "DN" , |
||
ICallback | cBack = null |
||
) |
The same as GDAL's gdal_polygonize utility.
See documentation here: http://www.gdal.org/gdal_polygonize.html
Return a distance along the source polyline to a Point nearest the reference Shape
sourceLine must be a Polyline Shape. Returned Distance is measured from Point[0]. If resulting 'distance' would be greater than the length of sourceLine, then sourceLine's length is returned.
bool Utils.ReclassifyRaster | ( | string | Filename, |
int | bandIndex, | ||
string | OutputName, | ||
Array | LowerBounds, | ||
Array | UpperBounds, | ||
Array | NewValues, | ||
string | gdalOutputFormat, | ||
ICallback | cBack | ||
) |
Creates a new datasource by mapping data ranges of the specified band of input datasource to new values.
Filename | Filename of input GDAL raster datasource. |
bandIndex | Band index of input datasource to be processed. |
OutputName | Filename of output datasource. |
LowerBounds | Array of double type with lower bounds of mapping ranges. These values will be compared with values of input datasource. Must be sorted in ascending order. |
UpperBounds | Array of double type with upper bounds of mapping ranges. These values will be compared with values of input datasource. |
NewValues | Array of double type with values to be set for output datasource for each mapping range. |
gdalOutputFormat | GDAL format. See list here: http://www.gdal.org/formats_list.html. Not all of them are necessarily support creation and writing operations. |
cBack | Callback to report progress and errors. |
All 3 input arrays must be of the same size. In case of overlapping ranges the one located first will be used. Here is code sample with 5 data ranges using anonymous data type:
Removes colinear points from a shapefile.
A shapefile containing colinear points leads to the shapefile taking up unnecessary space since some points in the shapefile add detail to the display of the shapes.
Shapes | The shapefile to remove colinear points from. |
LinearTolerance | Points will be considered colinear if the distance in between them is with in this tolerance. This distance is measured in projected map coordinates. |
cBack | The ICallback object which will receive progress and error messages while colinear points are being removed. |
Shapefile Utils.ReprojectShapefile | ( | Shapefile | sf, |
GeoProjection | source, | ||
GeoProjection | target | ||
) |
Reprojects a shapefile.
sf | The input shapefile. |
source | The source projection. |
target | The target projection. |
Grid Utils.ShapefileToGrid | ( | Shapefile | Shpfile, |
bool | UseShapefileBounds, | ||
GridHeader | GrdHeader, | ||
double | Cellsize, | ||
bool | UseShapeNumber, | ||
short | SingleValue | ||
) |
This function is not implemented. Converts a shapefile to a grid.
Shpfile | The shapefile to be converted into a grid. |
UseShapefileBounds | Optional. A boolean value representing whether or not the grid will have the same extents as the shapefile. The default is True |
GrdHeader | Optional. The grid header to use to create the new grid. If UseShapefileBounds is set to true, the extents supplied in the grid header will be ignored when the grid is created. |
Cellsize | Optional. The cell size of the new grid. The default cell size is 30. |
UseShapeNumber | Optional. Specifies that the value of each cell in the grid should be the shape index. The default value is true. |
SingleValue | Optional. The value to use when creating the grid. This only applies when UseShapeNumber is set to false. The default value is 1. |
Merges two shapes in a shapefile to create a new shape.
Shapes | The shapefile containing the two shapes to be merged to create the new shape. |
IndexOne | The index of the first shape to be merged. |
IndexTwo | The index of the second shape to be merged. |
cBack | The ICallback object which will receive progress and error messages while the shapes are being merged. |
Creates a new shapefile with z values added from an elevation grid.
Shapefile | The shapefile to be converted to a new shapefile with z values. |
Grid | The elevation grid to get the z values from. |
cBack | The ICallback object which will receive progress and error messages while z values are being added to the shapefile. |
GeoProjection Utils.TileProjectionToGeoProjection | ( | tkTileProjection | Projection | ) |
Initializes GeoProjection object with projection used by specific tile service.
Projection | Projection used by tile service. |
Shapefile Utils.TinToShapefile | ( | Tin | Tin, |
ShpfileType | Type, | ||
ICallback | cBack | ||
) |
Creates a shapefile from a TIN object.
Tin | The TIN object to be used to create a new shapefile. |
Type | The type of the shapefile to be created. |
cBack | The ICallback object which will receive progress and error messages while shapefile is being created from the TIN. |
bool Utils.TranslateRaster | ( | string | bstrSrcFilename, |
string | bstrDstFilename, | ||
string | bstrOptions, | ||
ICallback | cBack | ||
) |
Converts raster data between different formats, potentially performing some operations like subsettings, resampling, and rescaling pixels in the process.
See the description of appropriate routine in GDAL Tools.
bstrSrcFilename | The name of the source file. |
bstrDstFilename | The name of the destination file. |
bstrOptions | Options of the routine. |
cBack | The callback object. |
|
getset |
The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.
|
getset |
The key may be used by the programmer to store any string data associated with the object.
|
get |
Retrieves the last error generated in the object.