Public Member Functions | Properties
Grid Class Reference

The grid object is used to represent a grid which can be added to the map. More...

List of all members.

Public Member Functions

bool AssignNewProjection (string Projection)
 Assign new projection to the grid.
void CellToProj (int Column, int Row, out double x, out double y)
 Uses a cell's column and row position to find the center of the cell in projected map coordinates.
bool Clear (object ClearValue)
 Clears all data in the grid, setting the value of all cells in the grid to the specified clear value.
bool Close ()
 Closes the grid.
Image CreateImageProxy (GridColorScheme ColorScheme)
 Creates a proxy image file to display grid data.
bool CreateNew (string Filename, GridHeader Header, GridDataType DataType, object InitialValue, bool InRam, GridFileType fileType, ICallback cBack)
 Creates a new grid.
GridColorScheme GenerateColorScheme (tkGridSchemeGeneration Method, PredefinedColorScheme Colors)
 Generates colour scheme for the grid.
GdalRasterBand get_Band (int bandIndex)
 Gets datasource band with specified index.
string get_ErrorMsg (int ErrorCode)
 Retrieves the error message associated with the specified error code.
object get_Value (int Column, int Row)
 Returns the value stored in the grid at the specified cell.
bool GetFloatWindow (int StartRow, int EndRow, int StartCol, int EndCol, ref float Vals)
 Returns an array with grid values which lie within specified bounds.
bool GetFloatWindow2 (int StartRow, int EndRow, int StartCol, int EndCol, ref double Vals)
 Returns an array with grid values which lie within specified bounds. Double overload of Grid.GetFloatWindow method.
bool GetRow (int Row, ref float Vals)
 The faster way to read the array values that are of a specific size.
bool GetRow2 (int Row, ref double Vals)
 Provides the faster way to read the array values that are of a specific size. Double overload of Grid.GetRow.
bool Open (string Filename, GridDataType DataType, bool InRam, GridFileType fileType, ICallback cBack)
 Opens a grid.
Image OpenAsImage (GridColorScheme Scheme, tkGridProxyMode proxyMode=tkGridProxyMode.gpmAuto, ICallback cBack=null)
 Opens grid as image.
bool OpenBand (int bandIndex)
 Makes the specified band of the grid active.
void ProjToCell (double x, double y, out int Column, out int Row)
 Converts a point in projected map coordinates to a cell (column, row) in the grid.
bool PutFloatWindow (int StartRow, int EndRow, int StartCol, int EndCol, ref float Vals)
 Sets an array of values for a given region of the grid.
bool PutFloatWindow2 (int StartRow, int EndRow, int StartCol, int EndCol, ref double Vals)
 Sets an array of values for a given region of the grid. Double overload of Grid.PutFloatWindow.
bool PutRow (int Row, ref float Vals)
 Provides The faster way to write the array values that are of a specific size.
bool PutRow2 (int Row, ref double Vals)
 Provides The faster way to write the array values that are of a specific size. Double overload of Grid.PutRow.
bool RemoveImageProxy ()
 Removes proxy image file created for grid display.
bool Resource (string newSrcPath)
 Changes the grid source without closing it.
GridColorScheme RetrieveColorScheme (tkGridSchemeRetrieval Method)
 Retrieves colour scheme from the grid.
GridColorScheme RetrieveOrGenerateColorScheme (tkGridSchemeRetrieval retrievalMethod, tkGridSchemeGeneration generateMethod, PredefinedColorScheme Colors)
 Tries to retrieve any existing color scheme associated with grid or generates a new one if none is found.
bool Save (string Filename, GridFileType GridFileType, ICallback cBack)
 Saves the grid.
void set_Value (int Column, int Row, object pVal)
 Sets the value of the specified cell of the grid.
bool SetInvalidValuesToNodata (double MinThresholdValue, double MaxThresholdValue)
 Sets invalid values to no data values.

Properties

GdalRasterBand ActiveBand [get, set]
 Gets the active band of the datasource.
int ActiveBandIndex [get]
 The index of the active band within grid.
tkCanDisplayGridWoProxy CanDisplayWithoutProxy [get]
 Gets the value indicating whether grid source can be displayed by Image class without creation of proxy file.
string CdlgFilter [get]
 Returns the common dialog filter containing all supported file extensions in string format.
GridDataType DataType [get]
 Returns the data type of the values stored in the grid.
Extents Extents [get]
 Gets extents of the grid.
string Filename [get]
 The filename associated with the object.
ICallback GlobalCallback [get, set]
 The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.
bool HasValidImageProxy [get]
 Gets the value indicating whether grid has a valid image proxy for visualization.
GridHeader Header [get]
 Returns the header of the grid.
bool InRam [get]
 Returns whether the grid is loaded in to RAM memory or not.
string Key [get, set]
 The key may be used by the programmer to store any string data associated with the object.
int LastErrorCode [get]
 Retrieves the last error generated in the object.
object Maximum [get]
 Returns the maximum value stored in the grid.
object Minimum [get]
 Returns the minimum value stored in the grid.
int NumBands [get]
 Gets the number of within the grid.
tkGridProxyMode PreferedDisplayMode [get, set]
 Gets or sets the value indicating how the grid should be displayed.
GridColorScheme RasterColorTableColoringScheme [get]
 Gets grid colour scheme object used for rendering of the image representation of the grid, in case the datasource has a color table (GTiff with indexed colors, for example).
tkGridSourceType SourceType [get]
 Gets the type of grid source, which defines a) whether any grid source is opened and b) if so, what the inner representation of grid by MapWinGIS.

Detailed Description

The grid object is used to represent a grid which can be added to the map.

dot_inline_dotgraph_41.png

Grid datasource holds values describing distribution of certain characteristic over territory (e.g. elevation, population, precipitation, etc.), but usually doesn't define how these values should be rendered. In most cases grid datasource have a single band, but there may be mutiband ones as well (NetCDF format for example).

To render a grid, a color scheme must be chosen which will define how grid values will be mapped to colors. Some datasources may hold such color scheme (for examples GTiff with indexed colors). In many other cases the choice of color scheme is arbitrary. Here is an example of the same grid rendered with 2 different color schemes (SummerMountains and DesertFires).

grid_pair.jpg

MapWinGIS doesn't render Grid class directly, but uses Image class to do it. The distinction between these two is:

By default MapWinGIS renders grid with hillshading effect which can be switched on/off and adjusted in GridColorScheme class.

Metadata about grid can be accessed through GridHeader object (Grid.Header property). It includes size, coordinate system and projection, etc.

Attention:
Grid.Header property must not be called multiple times in a loop as it can trigger reading the data from disk on each occasion.


A. TYPES OF GRID RENDERING.

MapWinGIS can render grid datasource in 2 different ways:

dot_inline_dotgraph_42.png

1. Direct rendering by Image class.

Grid rendering may also by applied to a single band of regular RGB image, displaying it with synthetic colors. See more information on direct grid rendering in description of Image class.

Note:
Internally grids can be handled by either GDAL drivers or MapWinGIS own drivers. There is no way to affect which one will be chosen, however it's possible to check which one is used by Grid.SourceType property. The significance of it is that grid formats not supported by GDAL can't rendered directly by Image class.

2. Creation of so called proxy image to render a grid.

For multiband datasources proxy image will be created for the band marked as active by Grid.ActiveBandIndex. Use Grid.OpenBand to change the index.

There is no visual differences between 2 methods of grid rendering, however performance may differ substantially.

B. COLOR SCHEME FOR GRID.

Color scheme for grids can be retrieved in the following ways:

The first 2 approaches are covered by Grid.RetrieveColorScheme. Grid.RetrieveOrGenerateColorScheme method will look for any existing color scheme first, and if nothing is available will resort to generation. This is recommended approach in the most scenarios.

To generate color scheme manually the following code can be used:

 var grid = some_code_to_open_grid;
 var scheme = new GridColorScheme();
 scheme.UsePredefined((double)grid.Minimum, (double)grid.Maximum, PredefinedColorScheme.SummerMountains);
 scheme.ApplyColoringType(ColoringType.Hillshade);

See PredefinedColorScheme enumerations for available colors. Hillshading effect can be turned on/off with GridColorScheme.ApplyColoringType or by changing coloring of individual breaks (GridColorBreak.ColoringType).

C. HOW TO ADD GRID TO THE MAP.

Depending on requirements it can be done in fully automatic way with a single line or code (which is the best thing to do in most cases), or with manual coding if default behaviour isn't suitable. The approaches can be classified as:

dot_inline_dotgraph_43.png
Attention:
The samples below assume that the following variables are defined:
 string filename = @"d:\grid.asc";
 Utils ut = new Utils();

1. Using FileManager class.

The most generic one:

 axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosAutoDetect, true);

With creation of proxy image:

 int handle = axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosProxyForGrid, true);

Opening as direct grid. Along with usual reasons (invalid filename, corrupted file), the approach may fail in case:

 var gs = new GlobalSettings();
 gs.MaxNoProxyGridSizeMb = 100.0;    // size in MB; 20.0 is default value
 handle = axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosDirectGrid, true);

With a check that something was actually opened:

 int handle = axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosAutoDetect, true);
 if (handle != -1 && axMap1.FileManager.LastOpenIsSuccess) 
 {
     MessageBox.Show("Grid was added to the map. Open strategy: " + axMap1.FileManager.LastOpenStrategy.ToString());
 }
 else
 {
     MessageBox.Show("Failed to open grid: " + ut.ErrorMsgFromObject(axMap1.FileManager));
 }

Using custom instance of FileManager:

 var fm = new FileManager();
 if (fm.get_CanOpenAs(filename, tkFileOpenStrategy.fosDirectGrid))
 {
    var img = fm.OpenRaster(filename, tkFileOpenStrategy.fosDirectGrid, null);
    if (img == null)
    {
        MessageBox.Show("Failed to open grid: " + ut.ErrorMsgFromObject(fm) + "; Open strategy: " + fm.LastOpenStrategy);
    }
    else
    {
        int handle = axMap1.AddLayer(img, true);
    }
 }

2. Passing Grid to AxMap.AddLayer method.

The following logic will be executed:

The selection of rendering mode depends on:

See details in description of tkGridProxyMode enumeration.

The selection of proxy format depends on GlobalSettings.GridProxyFormat property.

A color scheme used for rendering will be written to disk with:

For direct rendering saving of color scheme to disk can be disabled with GlobalSettings.SaveGridColorSchemeToFile property.

The selection of color scheme depends on:

 var grid = new Grid();
 if (grid.Open(filename, GridDataType.UnknownDataType, true, GridFileType.UseExtension, null))
 {
    grid.PreferedDisplayMode = tkGridProxyMode.gpmAuto;   // or other mode if needed
    int handle = axMap1.AddLayer(grid, true);
    var img = axMap1.get_Image(handle);
    if (img != null)
    {
        MessageBox.Show("Grid was opened. Rendering: " + (img.IsGridProxy ? "using proxy" : "direct"));
    }
    else
    {
        MessageBox.Show("To add grid to map: " + axMap1.get_ErrorMsg(axMap1.LastErrorCode));
    }
    grid.Close();   // we no longer need it as Image class is used for rendering
 }
 else
 {
    MessageBox.Show("Failed to open grid: " + ut.ErrorMsgFromObject(grid));
 }

3. Manual opening/creation of Image for Grid.

With automatic selection of rendering mode:

 var grid = new Grid();
 if (grid.Open(filename, GridDataType.UnknownDataType, true, GridFileType.UseExtension, null))
 {
     var scheme = grid.RetrieveOrGenerateColorScheme(tkGridSchemeRetrieval.gsrAuto, tkGridSchemeGeneration.gsgGradient, PredefinedColorScheme.SummerMountains);
     var img = grid.OpenAsImage(scheme, tkGridProxyMode.gpmAuto, null);
     if (img != null)
     {
         int handle = axMap1.AddLayer(img, true);
     }
     else
     {
         MessageBox.Show("Failed to create image representation for the grid: " + ut.ErrorMsgFromObject(grid));
     }
     grid.Close();   // we no longer need it as Image class is used for rendering
 }
 else
 {
     MessageBox.Show("Failed to open grid: " + ut.ErrorMsgFromObject(grid));
 }

Opening for direct rendering without using Grid class:

 var image = new Image();
 if (image.Open(filename, ImageType.USE_FILE_EXTENSION, false, null))
 {
     if (image.IsRgb)
     {
         MessageBox.Show("It's not a grid.");
     }
     else
     {
         image.ImageColorScheme = PredefinedColorScheme.SummerMountains;     // or any other
         int handle = axMap1.AddLayer(image, true);
         if (handle == -1)
         {
             MessageBox.Show("Failed to open image: " + axMap1.get_ErrorMsg(axMap1.LastErrorCode));
         }
         else
         {
             MessageBox.Show("Data source is rendered as: " + (image.GridRendering ? "grid" : "image"));
         }
     }
 }
 else
 {
     MessageBox.Show("Failed to open image: " + ut.ErrorMsgFromObject(image));
 }

Manual creation of image proxy and color scheme:

 var grid = new Grid();
 if (grid.Open(filename, GridDataType.UnknownDataType, true, GridFileType.UseExtension, null))
 {
     var scheme = new GridColorScheme();
     scheme.UsePredefined((double)grid.Minimum, (double)grid.Maximum, PredefinedColorScheme.SummerMountains);
     scheme.ApplyColoringType(ColoringType.Hillshade);
 
     // grid.CreateImageProxy(scheme) can be used as well
     var img = ut.GridToImage2(grid, scheme, tkGridProxyFormat.gpfTiffProxy, false, null);
     if (img == null)
     {
         MessageBox.Show("Failed to create proxy image for grid:" + ut.ErrorMsgFromObject(ut));
     }
     else
     {
         int handle = axMap1.AddLayer(img, true);
     }
 
     grid.Close();   // we no longer need it as Image class is used for rendering
 }
 else
 {
     MessageBox.Show("Failed to open grid: " + ut.ErrorMsgFromObject(grid));
 }

To work with image proxies directly the following API members can be used: Grid.CreateImageProxy, Grid.HasValidImageProxy, Grid.RemoveImageProxy, Image.IsGridProxy.

D. Reading and editing the values.

Grids can be opened in either in-memory or disk based mode. Grid values can be retrieved and edited using:

For in-memory mode to save the changes to disk Grid.Save methods must be called. In disk-based mode the changes are saved automatically.

The size of grid can be obtained from its header (GridHeader.NumberRows, GridHeader.NumberCols).

For multiband datasource to read or edit values in the band other than first one use Grid.OpenBand.

 bool inRam = true;
 var grid = new Grid();
 if (grid.Open(filename, GridDataType.UnknownDataType, inRam, GridFileType.UseExtension, null))
 {
     var header = grid.Header;   // better to cache it in variable to avoid multiple reading from disk
     double noData = (double)header.NodataValue;
     for (int i =0; i < header.NumberCols; i++)
     {
         for (int j = 0; j < header.NumberCols; j++)
         {
             double val = grid.get_Value(i, j)
             if (val != noData && val > 1000)
             {
                 grid.set_Value(i, j, noData);
             }
         }
     }
 
     // when inRam is set to false no saving is needed
     if (!grid.Save(grid.Filename, GridFileType.UseExtension, null ))
     {
         MessageBox.Show("Failed to save changes: " + ut.ErrorMsgFromObject(grid));
     }
     grid.Close();
 }
 else
 {
     MessageBox.Show("Failed to open grid: " + ut.ErrorMsgFromObject(grid));
 }

E. Coordinate system and projection.

Information about geographic coordinate system and projection of grid can be retrieved using GridHeader.GeoProjection property. It is used by AxMap control when AxMap.GrabProjectionFromData is true. However grid can also be rendered fine if no coordinate system is specified, although projection aware functionality of MapWinGIS (tiles, scalebar) will be unavailable or won't function properly.

The location and scaling of grid in world coordinates is defined by GridHeader.XllCenter, GridHeader.YllCenter, GridHeader.dX, GridHeader.dY. While Grid.CellToProj, Grid.ProjToCell can be used to convert from cell coordinates to world coordinates.

Information about coordinates system and projection will be copied to output image when a proxy for the grid is created by Utils.GridToImage2 and all other API members which are using this method.

 var grid = new Grid();
 if (grid.Open(filename, GridDataType.UnknownDataType, inRam, GridFileType.UseExtension, null))
 {
     var gp = grid.Header.GeoProjection;
     MessageBox.Show(gp.IsEmpty() ? "No coordinates system for grid is specified." :  "Coordinate system for grid: " + grid.Header.GeoProjection.ExportToWKT());
     if (gp.IsEmpty)
     {
         double x, y;
         grid.CellToProj(0, 0, out x, out y);
         MessageBox.Show(string.Format("World coordinates of the first cell: x={0}; y={1}", x, y));
     }
     grid.Close();
 }

F. Support of GDAL overviews (version 4.9.2):

When opening grids MapWinGIS will recoginze existing GDAL overviews and will automatically create new overviews if needed (GlobalSettings.MinOverviewWidth). By default (GlobalSettings.GridProxyMode = gpmAuto) overviews option will always be chosen over proxy image creation, as it takes significantly less time. For original grids external overviews will be created (.ovr file), for proxy images - built-in overviews.
The use of proxy images for grid can still occur under following conditions:


Member Function Documentation

bool Grid.AssignNewProjection ( string  Projection)

Assign new projection to the grid.

Parameters:
ProjectionProjection string in proj4 format.
Returns:
True on success or false otherwise.
void Grid.CellToProj ( int  Column,
int  Row,
out double  x,
out double  y 
)

Uses a cell's column and row position to find the center of the cell in projected map coordinates.

Parameters:
ColumnThe column of the cell to find the center in projected map coordinates.
RowThe row of the cell to find the center in projected map coordinates.
xReturns the x projected map coordinate of the center of the specified cell.
yReturns the y projected map coordinate of the center of the specified cell.
bool Grid.Clear ( object  ClearValue)

Clears all data in the grid, setting the value of all cells in the grid to the specified clear value.

Parameters:
ClearValueThe value to set all of the grid's cells to.
Returns:
A boolean value representing the success or failure of clearing the grid.
bool Grid.Close ( )

Closes the grid.

Returns:
A boolean value representing the success or failure of closing the grid.

Creates a proxy image file to display grid data.

Parameters:
ColorSchemeColour scheme which specified how the data will be visualized.
Returns:
Created image proxy or null if the operation failed.

The format of proxy can be changed in GlobalSettings.GridProxyFormat.

New API 4.9.1:
Added in version 4.9.1
bool Grid.CreateNew ( string  Filename,
GridHeader  Header,
GridDataType  DataType,
object  InitialValue,
bool  InRam,
GridFileType  fileType,
ICallback  cBack 
)

Creates a new grid.

Parameters:
FilenameThe filename for the new grid.
HeaderThe header defining the attributes of the new grid.
DataTypeThe data type of the new grid.
InitialValueThe initial value for each cell of the new grid.
InRamOptional. A boolean value representing the grid being stored in memory(RAM) when True, and the grid being stored on disk when False.
fileTypeOptional. The grid file type.
cBackOptional. The ICallback object that will receive the progress and error events during the creation of the new grid.
Returns:
A boolean value representing the success or failure of the creation of the new grid.

Generates colour scheme for the grid.

Parameters:
MethodMethod of generation to be used.
ColorsPredefined colour scheme to be mapped to the values of grid.
Returns:
Generated colour scheme or null if the operation failed.
New API 4.9.1:
Added in version 4.9.1
GdalRasterBand Grid.get_Band ( int  bandIndex)

Gets datasource band with specified index.

Parameters:
bandIndexIndex of the band.
Returns:
The band or null if index is not valid.
New API 4.9.4:
Added in version 4.9.4
string Grid.get_ErrorMsg ( int  ErrorCode)

Retrieves the error message associated with the specified error code.

Parameters:
ErrorCodeThe numeric code of error returned by Grid.LastErrorCode.
Returns:
The description of the error.
object Grid.get_Value ( int  Column,
int  Row 
)

Returns the value stored in the grid at the specified cell.

Parameters:
ColumnThe column representing the cell for which the value is required.
RowThe row representing the cell for which the value is required.
Returns:
The value stored in the grid in the specified cell.
bool Grid.GetFloatWindow ( int  StartRow,
int  EndRow,
int  StartCol,
int  EndCol,
ref float  Vals 
)

Returns an array with grid values which lie within specified bounds.

For inner use or C++ use only. Only a single value will be returned to .NET.

Parameters:
StartRowThe start row of the window.
EndRowThe end row of the window.
StartColThe start colour of the window.
EndColThe end colour of the window.
ValsA supposed array (only a single value in .NET).
Returns:
True on success and false otherwise.
bool Grid.GetFloatWindow2 ( int  StartRow,
int  EndRow,
int  StartCol,
int  EndCol,
ref double  Vals 
)

Returns an array with grid values which lie within specified bounds. Double overload of Grid.GetFloatWindow method.

For inner use or C++ use only. Only a single value will be returned to .NET.

Parameters:
StartRowThe start row of the window.
EndRowThe end row of the window.
StartColThe start colour of the window.
EndColThe end colour of the window.
ValsA supposed array (only a single value in .NET).
Returns:
True on success and false otherwise.
New API 4.9.1:
Added in version 4.9.1
bool Grid.GetRow ( int  Row,
ref float  Vals 
)

The faster way to read the array values that are of a specific size.

The row is the integer row to read from the grid object. The vals variable is actually the first element of the array of floats that you want to be populated with the values from the grid. Since arrays are stored sequentially in memory, passing the first element allows the prediction of where the other values must go. It is very important that you always dimension the array as being of type float, and always make sure that you dimension it from 0 to numCols - 1.

Parameters:
RowThe Integer value of the row to retrieve values for.
ValsReference to the first element of the array of floats that will hold the row of values.
Returns:
True on success and false otherwise.
bool Grid.GetRow2 ( int  Row,
ref double  Vals 
)

Provides the faster way to read the array values that are of a specific size. Double overload of Grid.GetRow.

The row is the integer row to read from the grid object. The vals variable is actually the first element of the array of floats that you want to be populated with the values from the grid. Since arrays are stored sequentially in memory, passing the first element allows the prediction of where the other values must go. It is very important that you always dimension the array as being of type double, and always make sure that you dimension it from 0 to numCols - 1.

Parameters:
RowThe Integer value of the row to retrieve values for.
ValsReference to the first element of the array of doubles that will hold the row of values.
Returns:
True on success and false otherwise.
New API 4.9.1:
Added in version 4.9.1
bool Grid.Open ( string  Filename,
GridDataType  DataType,
bool  InRam,
GridFileType  fileType,
ICallback  cBack 
)

Opens a grid.

Parameters:
FilenameThe filename of the grid to be opened.
DataTypeOptional. The data type of the grid to be opened.
InRamOptional. A boolean value representing whether the grid will be stored in RAM or on disk.
fileTypeOptional. The file type of the grid. The default file type is "Use Extension".
cBackOptional. The ICallback object that will receive the progress and error events during the creation of the new grid.
Returns:
A boolean value that represents the success or failure of opening the grid.
Image Grid.OpenAsImage ( GridColorScheme  Scheme,
tkGridProxyMode  proxyMode = tkGridProxyMode.gpmAuto,
ICallback  cBack = null 
)

Opens grid as image.

Parameters:
SchemeColour scheme which specifies how grid will be visualized.
proxyModeProxy mode to be used.
cBackCallback interface.
Returns:
Resulting image object or null if the operation failed.

Depending on the proxy mode, grid datasource can be opened directly, or a proxy file can be created.

New API 4.9.1:
Added in version 4.9.1
bool Grid.OpenBand ( int  bandIndex)

Makes the specified band of the grid active.

Parameters:
bandIndexIndex of the band to be set active.
Returns:
True on success and false otherwise.
New API 4.9.0:
Added in version 4.9.0
void Grid.ProjToCell ( double  x,
double  y,
out int  Column,
out int  Row 
)

Converts a point in projected map coordinates to a cell (column, row) in the grid.

If the point lies outside the bounds of the grid, a column and row are returned which are outside the boundaries of the grid. For example, if the point lies to the left or lies below the grid boundaries, a negative column or row will be returned. Similarly, if the point lies above or to the right of the grid boundaries, a column or row which is greater than the number of columns or rows will be returned.

Parameters:
xThe x projected map coordinate for which the corresponding cell in the grid is required.
yThe y projected map coordinate for which the corresponding cell in the grid is required.
ColumnThe column the specified point lies within. This value may not be within the valid bounds of the grid.
RowThe row the specified point lies within. This value may not be within the valid bounds of the grid.
bool Grid.PutFloatWindow ( int  StartRow,
int  EndRow,
int  StartCol,
int  EndCol,
ref float  Vals 
)

Sets an array of values for a given region of the grid.

Parameters:
StartRowThe start row of the window.
EndRowThe end row of the window.
StartColThe start colour of the window.
EndColThe end colour of the window.
ValsA supposed array (only a single value in .NET).
Returns:
True on success and false otherwise.
bool Grid.PutFloatWindow2 ( int  StartRow,
int  EndRow,
int  StartCol,
int  EndCol,
ref double  Vals 
)

Sets an array of values for a given region of the grid. Double overload of Grid.PutFloatWindow.

Parameters:
StartRowThe start row of the window.
EndRowThe end row of the window.
StartColThe start colour of the window.
EndColThe end colour of the window.
ValsA supposed array (only a single value in .NET).
Returns:
True on success and false otherwise.
New API 4.9.1:
Added in version 4.9.1
bool Grid.PutRow ( int  Row,
ref float  Vals 
)

Provides The faster way to write the array values that are of a specific size.

The row is the integer row to read from the grid object. The vals variable is actually the first element of the array of floats that you want to be populated with the values from the grid. Since arrays are stored sequentially in memory, passing the first element allows the prediction of where the other values must go. It is very important that you always dimension the array as being of type float, and always make sure that you dimension it from 0 to numCols - 1.

Parameters:
RowThe Integer value of the row to retrieve values for.
ValsReference to the first element of the array of floats that will hold the row of values.
Returns:
True on success.
bool Grid.PutRow2 ( int  Row,
ref double  Vals 
)

Provides The faster way to write the array values that are of a specific size. Double overload of Grid.PutRow.

The row is the integer row to read from the grid object. The vals variable is actually the first element of the array of floats that you want to be populated with the values from the grid. Since arrays are stored sequentially in memory, passing the first element allows the prediction of where the other values must go. It is very important that you always dimension the array as being of type float, and always make sure that you dimension it from 0 to numCols - 1.

Parameters:
RowThe Integer value of the row to retrieve values for.
ValsReference to the first element of the array of doubles that will hold the row of values.
Returns:
True on success.
New API 4.9.1:
Added in version 4.9.1

Removes proxy image file created for grid display.

Returns:
True on success or if there is no image proxy and false if the operation failed.

Only the proxy format set in GlobalSettings.GridProxyFormat will be removed.

New API 4.9.1:
Added in version 4.9.1
bool Grid.Resource ( string  newSrcPath)

Changes the grid source without closing it.

Parameters:
newSrcPathThe name of the new file source.
Returns:
True on success and false otherwise.

Retrieves colour scheme from the grid.

Parameters:
MethodRetrieval method. Use Auto to try all the available method.
Returns:
Colour scheme object or null if the operation failed.

Is different from Grid.GenerateColorScheme, as it get colour scheme already stored in the grid itself or as an external .mwleg file rather than creating a completely new one.

New API 4.9.1:
Added in version 4.9.1

Tries to retrieve any existing color scheme associated with grid or generates a new one if none is found.

Parameters:
retrievalMethodColour scheme retrieval method.
generateMethodColour scheme generation method
ColorsPredefined set of colours to be mapped to grid values during generation process.
Returns:
Color scheme or null if both retrieval and generation failed.
New API 4.9.1:
Added in version 4.9.1
bool Grid.Save ( string  Filename,
GridFileType  GridFileType,
ICallback  cBack 
)

Saves the grid.

Parameters:
FilenameOptional. The filename the grid will be saved under. If no filename is specified the filename in the grid's Filename property is used.
GridFileTypeOptional. The file type to save the grid as. If no type is specified, the type stored in the grid object is used.
cBackOptional. The ICallback object that will receive the progress and error events during the creation of the new grid.
Returns:
A boolean value representing the success or failure of saving the grid.
void Grid.set_Value ( int  Column,
int  Row,
object  pVal 
)

Sets the value of the specified cell of the grid.

Parameters:
ColumnThe index of the cell's column.
RowThe index of the cell's row.
pValThe new value as variant data type.
bool Grid.SetInvalidValuesToNodata ( double  MinThresholdValue,
double  MaxThresholdValue 
)

Sets invalid values to no data values.

Parameters:
MinThresholdValueThe minimum valid value.
MaxThresholdValueThe maximum valid value.
Returns:
True in success and false otherwise.

Property Documentation

Gets the active band of the datasource.

New API 4.9.4:
Added in version 4.9.4

The index of the active band within grid.

Active band will be used on data extraction operation like Grid.get_Value, Grid.GetFloatWindow and during creation of image proxy.

New API 4.9.0:
Added in version 4.9.0

Gets the value indicating whether grid source can be displayed by Image class without creation of proxy file.

Check return value for the reason whey such rendering isn't possible.

New API 4.9.1:
Added in version 4.9.1
string Grid.CdlgFilter [get]

Returns the common dialog filter containing all supported file extensions in string format.

Returns the data type of the values stored in the grid.

Gets extents of the grid.

New API 4.9.0:
Added in version 4.9.0
string Grid.Filename [get]

The filename associated with the object.

The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.

Deprecated:
v4.9.3 Use GlobalSettings.ApplicationCallback instead.

Gets the value indicating whether grid has a valid image proxy for visualization.

To be considered valid the proxy must have proper name (with "_proxy" postfix) and colour scheme file (.mwleg). Both this files must have older creation date than the grid source file itself.

New API 4.9.1:
Added in version 4.9.1

Returns the header of the grid.

bool Grid.InRam [get]

Returns whether the grid is loaded in to RAM memory or not.

string Grid.Key [get, set]

The key may be used by the programmer to store any string data associated with the object.

int Grid.LastErrorCode [get]

Retrieves the last error generated in the object.

object Grid.Maximum [get]

Returns the maximum value stored in the grid.

object Grid.Minimum [get]

Returns the minimum value stored in the grid.

int Grid.NumBands [get]

Gets the number of within the grid.

New API 4.9.0:
Added in version 4.9.0

Gets or sets the value indicating how the grid should be displayed.

This value will be used in AxMap.AddLayer and Grid.OpenAsImage methods.

New API 4.9.1:
Added in version 4.9.1

Gets grid colour scheme object used for rendering of the image representation of the grid, in case the datasource has a color table (GTiff with indexed colors, for example).

Gets the type of grid source, which defines a) whether any grid source is opened and b) if so, what the inner representation of grid by MapWinGIS.

The functionality and behaviour of various source types may differ.

New API 4.9.0:
Added in version 4.9.0
 All Classes Files Functions Enumerations Properties Events