MapWinGIS:Grid CreateNew

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

CreateNew

Creates a new grid.
See also GridHeader and GridDataType and GridFileType


VB.NET Usage

Function CreateNew(Filename As String, Header As MapWinGIS.GridHeader, DataType As MapWinGIS.GridDataType, InitialValue As Object, Optional InRam As Boolean, Optional FileType As MapWinGIS.GridFileType, Optional cBack As MapWinGIS.ICallback) As Boolean

            Parameters

Filename

The filename for the new grid.
Header The header defining the attributes of the new grid.
DataType The data type of the new grid.
InitialValue The initial value for each cell of the new grid.
InRam Optional. A boolean value representing the grid being stored in memory(RAM) when True, and the grid being stored on disk when False.
FileType Optional. The grid file type.
cBack Optional. The ICallback object that will receive the progress and error events during the creation of the new grid.
ReturnValue A boolean value representing the success or failure of the creation of the new grid.

Sample Code

    Private Sub CreateNewGrid()
        Dim row As Integer, col As Integer
        Dim grid As New MapWinGIS.Grid()
        Dim newgrid As New MapWinGIS.Grid()
        'Create the new grid using the old grid's header and data type
        newgrid.CreateNew("", grid.Header, grid.DataType, 0, True, MapWinGIS.GridFileType.Ascii, Me)
        'Populate the new grid with the other grid's values
        For row = 0 To newgrid.Header.NumberRows - 1
            For col = 0 To newgrid.Header.NumberCols - 1
                newgrid.Value(col, row) = grid.Value(col, row)
            Next
        Next
        'Save the new grid
        newgrid.Save("C:\output.asc")
        'Close the grid
        grid.Close()
        'Close the new grid
        newgrid.Close()
    End Sub
  

VB 6 Usage
Function CreateNew(Filename As String, Header As GridHeader, DataType As GridDataType, InitialValue As Object, Optional InRam As Boolean, Optional FileType As GridFileType, Optional cBack As ICallback) As Boolean
            Parameters

Filename

The filename for the new grid.
Header The header defining the attributes of the new grid.
DataType The data type of the new grid.
InitialValue The initial value for each cell of the new grid.
InRam Optional. A boolean value representing the grid being stored in memory(RAM) when True, and the grid being stored on disk when False.
FileType Optional. The grid file type.
cBack Optional. The ICallback object that will receive the progress and error events during the creation of the new grid.
ReturnValue A boolean value representing the success or failure of the creation of the new grid.

Sample Code

    Private Sub CreateNewGrid()
        Dim row As Long, col As Long
        Dim grid As New MapWinGIS.grid
        Dim newgrid As New MapWinGIS.grid
        'Create the new grid using the old grid's header and data type
        newgrid.CreateNew "", grid.Header, grid.DataType, 0, True, MapWinGIS.GridFileType.Ascii, Me
        'Populate the new grid with the other grid's values
        For row = 0 To newgrid.Header.NumberRows - 1
            For col = 0 To newgrid.Header.NumberCols - 1
                newgrid.Value(col, row) = grid.Value(col, row)
            Next
        Next
        'Save the new grid
        newgrid.Save ("C:\output.asc")
        'Close the grid
        grid.Close
        'Close the new grid
        newgrid.Close
    End Sub

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGIS:Grid_CreateNew"

This page has been accessed 2,696 times. This page was last modified on 9 November 2005, at 16:33.