MapWinGIS:Shapefile PointInShapefile

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

PointInShapefile

Gets the index of the first shape the specified point lies within. If there are no shapes the point lies within, -1 is returned. Note: If you are making extensive use of this function for a shapefile, you may be able to improve the performance of your application by using BeginPointInShapefile before your call(s) to PointInShapefile, and EndPointInShapefile after you are finished calling PointInShapefile. This loads all of the points for all of the shapefile's shapes into memory to speed up calculating whether a point lies within a shape or not.
See also BeginPointInShapefile and EndPointInShapefile


VB.NET Usage

Function PointInShapefile(x As Double, y As Double) As Integer

            Parameters

x

The x coordinate in projected map coordinates of the point to be tested.
y The y coordinate in projected map coordinates of the point to be tested.
ReturnValue The shape index of the first shape the point lies within, or -1 if there are no shapes the point lies within.

Sample Code

    Private Sub PointInShapefile()
        Dim sf As New MapWinGIS.Shapefile()
        Dim x As Double, y As Double
        Dim shapeindex As Integer
        'Set the values for x and y in projected map coordinates
        x = 3000
        y = 2500
        'Get the shape index of any shape in the shapefile that the point lies within, if any
        sf.BeginPointInShapefile() 
        shapeindex = sf.PointInShapefile(x, y)
        sf.EndPointInShapefile() 
    End Sub
  

VB 6 Usage
Function PointInShapefile(x As Double, y As Double) As Long
            Parameters

x

The x coordinate in projected map coordinates of the point to be tested.
y The y coordinate in projected map coordinates of the point to be tested.
ReturnValue The shape index of the first shape the point lies within, or -1 if there are no shapes the point lies within.

Sample Code

    Private Sub PointInShapefile()
        Dim sf As New MapWinGIS.Shapefile
        Dim x As Double, y As Double
        Dim shapeindex As Long
        'Set the values for x and y in projected map coordinates
        x = 3000
        y = 2500
        'Get the shape index of any shape in the shapefile that the point lies within, if any
        sf.BeginPointInShapefile() 
        shapeindex = sf.PointInShapefile(x, y)
        sf.EndPointInShapefile() 
    End Sub

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

This page has been accessed 3,453 times. This page was last modified on 4 December 2009, at 07:32.