MapWindow Script Directory
Script: lines measurement1
Imports MapWindow.Interfaces
Imports MapWinGIS
Imports System
Imports System.Windows.Forms
Imports System.Collections
Imports Microsoft.VisualBasic
'***********************************************
'Simple script for extracting the x and y points
'features in a shapefile.
'Dan Ames March 8, 2007
'***********************************************
Public Module XYPoints
'***********************
'* Main
'***********************
Public Sub ScriptMain(ByRef m_MapWin As IMapWin)
dim sf as new MapWinGIS.shapefile
dim sh as new MapWinGIS.shape
dim i as integer, j as integer
dim outputstring as string = ""
dim FileName as string = "C:\BASINS\data\01080105\cat.shp"
sf.open(FileName)
'Cycle through all shapes in the shapefile
for i = 0 to sf.numshapes - 1
'Now get the current shape at position i (polygon or polyline)
sh = sf.shape(i)
'Now cycle through all of its points
for j = 0 to sh.numpoints -1
'now you can get to the x,y values on each point and add them to a big long string
outputstring = outputstring & vbCrLf & " Shape: " & i & vbTab & "Point: "
outputstring = outputstring & j & vbTab & "X: " & sh.point(j).x & vbTab & "Y: " & sh.point(j).y
next j
next i
'now save the output string to a file or something. I'll just show it in a popup box
FileOpen (1,"c:\output.txt",OpenMode.Output,OpenAccess.Write)
PrintLine(1, "X and Y Data Extracted from:" & vbCrLf & FileName)
PrintLine(1, outputstring)
FileClose (1)
Shell ("notepad.exe c:\output.txt", vbNormalFocus)
End Sub
End Module
Back









