Glenn,
Thanks for the info but most of it is Greek to me :-) I don't have a
programmer background and I'm not sure if I'm using VB or VB.net. I'm
using the Visual Studio Express (Free) software and have found samples
of code form Google Groups that I've pulled together to automate the
process. Very cool and fun stuff I just don't have a clue...
Here is my code. Maybe this will help:
Public Class Feature2Raster
Dim objPathIN
Dim objPathOUT
Dim objShell
Dim objFolder
Dim objFolderItem
Dim gp
Dim InCellSize
Dim TB5
Dim FCount As Integer
Dim HowLong As Integer
Dim FNameCUT
Dim FNameFinal
Dim oSF
Dim foldr
Dim fils
Dim FName
Dim InFeatures
Dim InField
Dim OutRaster
Dim Feat
Dim FeatTyp
Dim tm
Dim dt
Dim WhatChar
Dim FileExt
Public Sub btnDoFBD_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles InputFolder.Click
'Select Folder to read Shape Files from
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
objShell = CreateObject("Shell.Application")
objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select Input folder for Shape Files:",
NO_OPTIONS, "My Computer")
objFolderItem = objFolder.Self
objPathIN = objFolderItem.Path
TextBox3.Text = objPathIN
'Display next message in Message Center
TextBox5.Text = Nothing
TextBox5.Text = "Select Output Folder"
End Sub
Public Sub OutPutFolder_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles OutPutFolder.Click
'Select Folder for Output files
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
objShell = CreateObject("Shell.Application")
objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select Output folder for Raster Files:",
NO_OPTIONS, "My Computer")
objFolderItem = objFolder.Self
objPathOUT = objFolderItem.Path
TextBox4.Text = objPathOUT
'Display next message in Message Center
TextBox5.Text = Nothing
TextBox5.Text = "Keyin All Feature related info and Select
Process Button"
End Sub
Public Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
'End Program
End
End Sub
Public Sub Main()
' Create the Geoprocessor object
gp = CreateObject("esriGeoprocessing.GPDispatch.1")
' Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/
Conversion Tools.tbx")
'Read files in selected folder
'Set Time/Day Stamp for begin Process
tm = TimeOfDay
dt = DateString
'Display next message in Message Center - this does not work
TextBox5.Text = Nothing
TextBox5.Text = "Proccessing...Please Wait..."
'Create Log File
Dim FSO, MyLogFile
FSO = CreateObject("Scripting.FileSystemObject")
MyLogFile = FSO.CreateTextFile(objPathOUT &
"\Feature2RasterFile.log")
'Write Start Time to Log File
With MyLogFile
.Write("Feature2Raster Processing Started @ " & dt & " " &
tm & vbCrLf & vbCrLf)
End With
'Get Input Folder
oSF = CreateObject("Scripting.FileSYStemOBJect")
foldr = oSF.GetFolder(objPathIN)
fils = foldr.Files
FName = ""
FCount = 0
'Define Default Parameters
'InCellSize = "3.5"
InCellSize = TextBox1.Text
'InField = "coord_z"
InField = TextBox2.Text
'Feat = "flora"
Feat = TextBox7.Text
'FeatTyp = "flora_species_point"
FeatTyp = TextBox8.Text
'FeatExt = "img"
FileExt = TextBox6.Text
'Write Parameters to Log File
With MyLogFile
.Write("Processing Parameters are listed below: " &
vbCrLf)
.Write("Input Folder: " & objPathIN & vbCrLf)
.Write("Output Folder: " & objPathOUT & vbCrLf)
.Write("Output File Extension: ." & FileExt & vbCrLf)
.Write("Feature: " & Feat & vbCrLf)
.Write("Feature Type: " & FeatTyp & vbCrLf)
.Write("Field: " & InField & vbCrLf)
.Write("Cell Size: " & InCellSize & vbCrLf & vbCrLf)
End With
'Process each Input File
For Each fL In fils
FCount = FCount + 1
FName = fL.Name
'InFeatures = objPathIN & "\" & FName & "\flora
\flora_species_point"
InFeatures = objPathIN & "\" & FName & "\" & Feat & "\" &
FeatTyp
'Trim Filename for Output File Name
WhatChar = "."
HowLong = Len(FName) - 4
'FNameCUT = Mid(FName, InStrRev(FName, WhatChar) -
HowLong)
FNameCUT = Mid(FName, 1, HowLong) & "." & FileExt
'Set Output File
'OutRaster = objPathOUT & "\" & FNameCUT & ".img"
OutRaster = objPathOUT & "\" & FNameCUT
'MsgBox("FName(FCount) are : " & vbCrLf &
"-----------------" & vbCrLf & arg3) '- - --------------------------
'Write Input & Output File Names to Log File
With MyLogFile
.Write("Feature2Raster Processing Input: " & FName &
vbCrLf)
'.Write("Feature2Raster Processing Output: " &
FNameCUT & ".img" & vbCrLf)
.Write("Feature2Raster Processing Output: " & FNameCUT
& vbCrLf)
End With
' Process: Feature to Raster...
gp.FeatureToRaster_conversion(InFeatures, InField,
OutRaster, InCellSize)
Next
'ReSet Time/Day Stamp for End Process
tm = TimeOfDay
dt = DateString
'Write Time/Day Stamp for End Process
With MyLogFile
.Write(vbCrLf)
.Write("Feature2Raster Processing Completed @ " & dt & " "
& tm)
.Close()
End With
MyLogFile = Nothing
FSO = Nothing
'MsgBox("There are " & FCount & " files Process from folder "
& objPathIN)
'MsgBox("File Names are : " & vbCrLf & "-----------------" &
vbCrLf & FName) '- - --------------------------
End Sub
Public Sub Process_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Process.Click
'Display next message in Message Center - this does not work
TextBox5.Update()
TextBox5.Text = Nothing
TextBox5.Text = "Proccessing...Please Wait..."
StartProcess()
'Call Main Program
Main()
'Display next message in Message Center
TextBox5.Text = Nothing
TextBox5.Text = "Process Complete with " & FCount & " files
processed"
End Sub
Public Sub StartProcess()
'Display next message in Message Center - this does not work
TextBox5.Text = Nothing
TextBox5.Text = "Proccessing...Please Wait..."
End Sub
Public Sub TextBox1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Public Sub TextBox2_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Public Sub TextBox3_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
Public Sub TextBox4_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Public Sub TextBox6_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox6.TextChanged
End Sub
Public Sub TextBox7_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox7.TextChanged
End Sub
Public Sub TextBox8_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox8.TextChanged
End Sub
Public Sub TextBox9_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
Public Sub TextBox3_Enter(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox3.TextChanged
' If the TextBox contains text, change its foreground and
background colors.
If TextBox3.Text = [String].Empty Then
TextBox3.Text = "Please Select Input Folder"
TextBox3.ForeColor = Color.Red
TextBox3.BackColor = Color.White
' Move the selection pointer to the end of the text of the
control.
TextBox3.Select(TextBox3.Text.Length, 0)
End If
End Sub
Public Sub Feature2Raster_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Display Input File path
TextBox3.Text = objPathIN
'Display Output File path
TextBox4.Text = objPathOUT
'Display next message in Message Center
TextBox5.Text = "Please Fill-in Form Top Down"
End Sub
End Class
> > Tim- Hide quoted text -
>
> - Show quoted text -