I have added two layers to the map, and they are visibly overlapping. One layer of polygons (5) and one layer of points (~10000). Trying to determine which polygons contain each of the points, using the following code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sfPolygon As New MapWinGIS.Shapefile()
Dim sfPoints As New MapWinGIS.Shapefile()
Dim i As Integer
Dim pt As New MapWinGIS.Point()
Dim iShp As Int32
sfPoints = AxMap1.get_GetObject(0)
sfPolygon = AxMap1.get_GetObject(1)
For i = 0 To sfPoints.NumShapes - 1
pt = sfPoints.Shape(i).Point(0)
iShp = sfPolygon.PointInShapefile(pt.x, pt.y)
ListBox1.Items.Add(i & " " & pt.x.ToString & " " & pt.y.ToString & " " & iShp)
The iShp variable returns (-1, not within any shape) for all of the points. What am I doing wrong?
My plan is to populate one field of the Points datatable with the index of the polygon that it lies within -- the ListBox is just for testing. Is this the correct way to attack this problem (ie, looping through all the points)?
I have one layer that is a parcel map, the other point is lat/long points plotted on that map and I'd like to know what parcel each point lays on.