Adding a Raster via text box

620
3
08-16-2010 11:42 AM
by Anonymous User
Not applicable
Original User: klaughl

I'm hoping to create a simple form tool that will allow access to our individual .tif aerial tiles (about 1 mi X 1 mi) for us to utilize them (at present, they're not being used at all). What I have is a command which calls a windows form (see Pic1). From my admittedly limited knowledge of ArcObjects and VB.NET, this should work, but it's not. When you click search, the window closes and nothing happens. Needless to say, I'm at a loss. See Pic2 to view the code for the search button (also, generically named Button1 in the actual code). I will also post it below as well.


Thanks!


Kevin Laughlin
Wood County, OH Auditor's Office
GIS Department





CODE:


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pString = ComboBox1.Text

        Dim mxDocument = CType(m_app.Document, IMxDocument)
        Dim focusMap = mxDocument.FocusMap
        Dim pMap = mxDocument.FocusMap

        Dim rasterLayer = New RasterLayerClass
        rasterLayer.Name = pString
        rasterLayer.CreateFromFilePath("\\10.8.31.2\11001WoodCo")

        focusMap.AddLayer(rasterLayer)
        pMap.MoveLayer(rasterLayer, pMap.LayerCount - 1)
        mxDocument.ActiveView.Refresh()
        mxDocument.UpdateContents()

    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


    End Sub
0 Kudos
3 Replies
RobertBerger
New Contributor III
Hi Kevin,

I am not sure I understand how your constructed string points to the location of the dataset. Is the data shared? Usually you would use a "\\machinename\folder\abc.tif" string. Alternatively, you can go through the workspace to open the directory, and get the dataset through the workspace.

Have you looked at the online help?
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Working_with_image_and_...

Hope this helps.

Robert
0 Kudos
by Anonymous User
Not applicable
Original User: klaughl

\\10.8.31.2 is our server location

\11001WoodCo is the a folder on the server where the .tif images are located

What I am trying (or really hoping) to do is for the user to be able to input tile number (say it's called 111111.tif) into the text or combo box and be able to load the data from there.

Thanks,

Kevin
0 Kudos
RobertBerger
New Contributor III
Kevin,

Can you open the dataset through the workspace? The code should look something like this:
Dim wsFact as IWorkspaceFactory
Set wsFact = new RasterWorkspaceFactory
Dim rasWs as IRasterWorkspace
Set rasWs = wsFact.OpenFromFile(path, 0)
Dim rasDs as IRasterDataset
Set rasDs = rasWs.OpenRasterDataset(name)

Then you can open the layer from the dataset. Path should be your \\10.8... and name would be 11111.tif.
Let me know if this works.

Robert
0 Kudos