MapWindow Home
Search MapWindow.org


  • Home
    • Download
    • Why MW
    • FAQ
    • Contact
  • Products
    • MapWindow
    • ActiveX
    • Plug-ins
  • Software Dev
    • Sample Code
    • Scripts
    • Source
    • Bugs
    • Support
    • Languages
  • Site Tools
    • Forums
    • Tutorials
    • Mailing Lists
    • Team
    • Site Stats
    • Links
  • Get Stuff
    • Buy a CD
    • Buy a T-Shirt
    • MW Book
    • ActiveX Book
    • Donate
    • Buy Support
  • Documentation
    • MWGIS App. User Guide
    • GISTools User Guide
    • MW Plug-ins Dev. Guide
    • MWGIS ActiveX Dev. Guide
    • MWGeoProc Dev. Guide

MapWinGIS:Grid ProjToCell

From MapWindow GIS

Jump to: navigation, search

ProjToCell

Converts a point in projected map coordinates to a cell (column, row) in the grid. Note: 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.


VB.NET Usage

Sub ProjToCell(x As Double, y As Double, ByRef Column As Integer, ByRef Row As Integer)

            Parameters

x

The x projected map coordinate for which the corresponding cell in the grid is required.
y The y projected map coordinate for which the corresponding cell in the grid is required.
Column Reference parameter. The column the specified point lies within. Note: This value may not be within the valid bounds of the grid.
Row Reference parameter. The row the specified point lies within. Note: This value may not be within the valid bounds of the grid.

Sample Code

    Private Sub ProjToCell()
        Dim grid As New MapWinGIS.Grid()
        Dim x As Double, y As Double
        Dim col As Integer, row As Integer
        'Set the point in projected map coordinates
        x = 130000
        y = 135000
        'Open a grid from disk
        grid.Open("C:\grid.asc")
        'Get the center of the cell in projected map coordinates stored in x and y
        grid.ProjToCell(x, y, col, row)
        'Display column and row of the specified point in a message box
        MsgBox("The column and row of the point: col = " + Str(col) + " row = " + Str(row))
        'Close the grid
        grid.Close()
    End Sub
  

VB 6 Usage
Sub ProjToCell(x As Double, y As Double, ByRef Column As Long, ByRef Row As Long)
            Parameters

x

The x projected map coordinate for which the corresponding cell in the grid is required.
y The y projected map coordinate for which the corresponding cell in the grid is required.
Column Reference parameter. The column the specified point lies within. Note: This value may not be within the valid bounds of the grid.
Row Reference parameter. The row the specified point lies within. Note: This value may not be within the valid bounds of the grid.

Sample Code

    Private Sub ProjToCell()
        Dim grid As New MapWinGIS.grid
        Dim x As Double, y As Double
        Dim col As Long, row As Long
        'Set the point in projected map coordinates
        x = 130000
        y = 135000
        'Open a grid from disk
        grid.Open ("C:\grid.asc")
        'Get the center of the cell in projected map coordinates stored in x and y
        grid.ProjToCell x, y, col, row
        'Display column and row of the specified point in a message box
        MsgBox ("The column and row of the point: col = " + Str(col) + " row = " + Str(row))
        'Close the grid
        grid.Close
    End Sub

Retrieved from "http://www.mapwindow.org/wiki/index.php/MapWinGIS:Grid_ProjToCell"
Views
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in / create account
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • Permanent link

Geospatial Software Lab

Copyright © 2008 - MapWindow Open Source Team
( last updated: November 12 2008.)
Home | Donate | Download | MapWindow GIS Desktop | MapWinGIS.ocx | Plug-ins | Contact | Lists | Bugs | Sample Code | Documentation
Code Repository | Open Source License | Discussion Forum | Wiki | Join the Team | Site Statistics | Links