Tuesday, November 2, 2010

ARC Objects---Framework--Programs

Program-1

checking seleted layer is featurelayer or group layer or raster alyer
--------------------------------------------
Public Sub CheckSelectedLayer()
Dim pMxDocument As IMxDocument
Set pMxDocument = Application.Document
Dim pLayer As ILayer
Set pLayer = pMxDocument.SelectedLayer
If TypeOf pLayer Is IGroupLayer Then
' we have a group layer (GroupLayer)
MsgBox pLayer.Name
ElseIf TypeOf pLayer Is IGeoFeatureLayer Then
' we have a feature layer
MsgBox pLayer.Name
ElseIf TypeOf pLayer Is IRasterLayer Then
' we are check raster layer
MsgBox pLayer.Name
End If
End Sub


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Program-2



Creating Menus and Submenus and add command items
--------------------------------------------------
Public Sub CreateMenu()
' Find the MainMenuBar.
Dim pMainMenuBar As ICommandBar
Set pMainMenuBar = Application.Document.CommandBars.Find(arcid.MainMenu)
' Create the new menu called "MyMenu" on the MainMenuBar.
Dim pNewMenu As ICommandBar
Set pNewMenu = pMainMenuBar.CreateMenu("MyMenu")
' Add a built in command to the new menu.
' The built in ArcID module is used to get the command ID for the AddData
' command.
pNewMenu.Add arcid.File_AddData

'creating submneus and add command items
With pNewMenu
Dim submenu As ICommandBar
Set submenu = pNewMenu.CreateMenu("Region", 0)
submenu.Add arcid.File_Export
Set submenu = pNewMenu.CreateMenu("Basin", 1)
submenu.Add arcid.PanZoom_FullExtent
End With


End Sub

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=
Program-3

Creating Menus and Submenus and add command items
--------------------------------------------------
Public Sub CreateMenu()
' Find the MainMenuBar.
Dim pMainMenuBar As ICommandBar
Set pMainMenuBar = Application.Document.CommandBars.Find(arcid.MainMenu)
' Create the new menu called "MyMenu" on the MainMenuBar.
Dim pNewMenu As ICommandBar
Set pNewMenu = pMainMenuBar.CreateMenu("MyMenu")
' Add a built in command to the new menu.
' The built in ArcID module is used to get the command ID for the AddData
' command.
pNewMenu.Add arcid.File_AddData

'creating submneus and add command items
With pNewMenu
Dim submenu As ICommandBar
Set submenu = pNewMenu.CreateMenu("Region", 0)
submenu.Add arcid.File_Export
Set submenu = pNewMenu.CreateMenu("Basin", 1)
submenu.Add arcid.PanZoom_FullExtent
End With


End Sub



=-=-=-=-==-=-=-=-=-==-=-==--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Program-4


Option Explicit
'creating toolbar
Sub FF()
Dim ss As ICommandBar
Set ss = ThisDocument.CommandBars.Create("dd", esriCmdBarTypeToolbar)

ss.Add arcid.File_AddData
End Sub

=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-==--=
Program-5


Sub ExecuteCmd()
Dim pCmdItem As ICommandItem
' Use ArcID module and the Name of the Save command
Set pCmdItem = Application.Document.CommandBars.Find(arcid.File_Save)
pCmdItem.Execute
end sub
--------

Sub ExecuteCmd2()
Dim pUID As New UID
Dim pCmdItem As ICommandItem
' Use the GUID of the Save command
pUID.Value = "{119591DB-0255-11D2-8D20-080009EE4E51}"
' or you can use the ProgID
' pUID.Value = "esriArcMapUI.MxFileMenuItem"
pUID.SubType = 3
Set pCmdItem = Application.Document.CommandBars.Find(pUID)
pCmdItem.Execute
End Sub

=-=-=-=-=-=-=-=-==-=-=-==-=-=-=-=-=-=-=-=-=-==-=-=-====-=-=-=



http://bitcofarm.com/home?r=Ramki009




Monday, February 1, 2010

Working with ArcMap


Introducing ArcMap
ArcMap
  • Used for creating, viewing, querying, editing, composing, and publishing maps
  • Maps usually present several types of info. about an area at once
  • The ex02.mxd map shows UM campus property, buildings, and streets
  • You can see the layers in this map listed in the table of contents
  • Each layer has a check box to turn them on or off in the map display
  • Within a layer, symbols are used to draw features. In this map, buildings and UM property are represented by areas (polygons) and streets are represented by lines
  • Each layer contains 2 kinds of information:
  • Spatial Information describes the location and shape of the geographic features
  • Attribute Information tells you about other characteristics of the features
Working with Maps
  • Exploring
You can visualize and interpret spatial relationships among features.
  • Analyzing
You can create new information and find hidden patterns by adding layers to a map.

  • Presenting Results
You can create map layouts for printing, embedding in other documents, or electronic publishing. When you save your map, all of your layout work, symbols, text, and graphics are preserved.

  • Customizing
  1. You can customize the ArcMap interface by adding or removing tools to or from existing toolbars or by creating custom toolbars.
  2. You can also use the Visual Basic for Applications (VBA) programming language included in ArcMap to create new tools and interfaces.
  • Programming
  1. You can build new interfaces for interacting with your maps and create new, specialized classes of features.
  2. ArcGIS is built on Microsoft’s Component Object Model (COM); all of the COM components are available to developers using a COM-compliant programming language.
The Tools toolbar contains frequently used tools to navigate around the map, find features, and get information



Undocked tool bar
Docked Tool Bar



  1. Open ArcMap (if necessary
    1. File – Open: ex03.mxd

Zooming to the Full Extent of the Map
  • To see an area of the map in greater detail, you can zoom in to the map
  • Click the Zoom-IN button
  • Drag a box around Michigan to zoom in to the state
  • Note: you can click the Previous Extent button to jump back to the previous extent
  • Click the Identify Features button and click on Michigan
  • When you click a feature with the Identify Features button, you can view the attributes of the feature from the Identify Results window that appears. If the tool finds more than one feature when you click, it lists each feature on the left side of the window. You can click the features in the list to view their attributes on the right.
  • Close the Identify Results window.
Finding Features in the Map
  • The Find button lets you search a map for features that match your search criteria. Let’s find the City of Ann Arbor.
  • Click the Find button
  • In the Find Text Box, type “Ann Arbor”
  • Click the In dropdown arrow and click cities. Click ‘In Field’, then click the dropdown arrow, and click AREANAME
  • Click Find.
  • Ann Arbor appears in the list of features at the bottom that the tool has found.
  • Right-click Ann Arbor and click Zoom to feature(s).
  • The map zooms to Ann Arbor. As the scale is now greater than 1:25,000,000, the City points features appear on the map. Also notice that the city names appear. The Labels for the cities layer are set to appear at a scale greater than or equal to 1:5,000,000.


  1. Another option on the list is ‘Create Bookmark’. A spatial bookmark preserves a particular map extent so you can zoom back to it whenever you want. Right-click Ann Arbor again and choose ‘Create Bookmark’
  2. A spatial bookmark has is created called ‘Ann Arbor.
  3. To go to this bookmark, click the ‘Full Extent’ button
  4. Click ‘Bookmarks’ on the main menu and choose ‘Ann Arbor’.
  5. Now the map is zoomed to the Ann Arbor book mark.
































Adding a Layer to a Map
  • Next, lets go to the ‘Lake Michigan’ Bookmark, which is a good extent for viewing the state of Michigan. Click Bookmarks, Lake Michigan.
  • Let’s add a layer of county boundaries.
  • Position the ArcMap and ArcCatalog windows so you can see both of them.
  • In the ArcCatalog tree, expand C:\temp\Exercises\data
  • Click the micounties_popsqmile.lyr file and drag it into the ArcMap display window to dump it there.
  • The layer shows micounties drawn with a graduated color ramp representing population per square mile.
  • A layer serves as a shortcut to the data. It also tells ArcMap how the data should be drawn. Layers are created from raw data, which is symbolized in a particular way and then saved as a layer (.lyr) file.


Adding features from a database
  • When you add features from a coverage, shapefile or database, they are all drawn with a single symbol.
  • Now you’ll add the parks features to your map.
  • Position the ArcMap and ArcCatalog windows so you can see them both.
  • Click to expand the michigan.mdb geodatabase folder in the C:\temp\Exercises\data folder.
  • Click and drag the miparks feature class into the ArcMap display window. miparks is a feature class – a collection of features represented with the same geometry (shape). In this case, the features are polygons which represent parks in Michigan. You will learn more about geodatabases containing feature datasets and feature classes as well as other GIS data types later.

Changing how features are drawn

If we wanted to visualize the parks in terms of square miles, we could symbolize them to reflect this better.
1. Right-click the parks layer in the table of contents and click Properties.
2. The Layer Properties dialog box appears. You can use this dialog box to inspect and change a wide variety of layer properties.
3. Click the Symbology tab near the top of the Properties dialog box.
4. Click Quantities.
5. Click Graduated symbols.
6. Click the Value dropdown arrow and click SQMI. This is the variable in the attribute table that contains the square miles for each park. ArcMap assigns the data to five classes using the Natural Breaks classification (Jenk’s method). The size of the circle symbols indicates the square miles of the parks. You want the color to be yellow (or something that will show up against the green counties background).

  • Click the template button. The Symbol Selector dialog box appears. Here you can
    choose predefined symbols, such as the Circle 1 symbol, or you can design your
    own symbols.


  • Click the template button. The Symbol Selector dialog box appears. Here you can
    choose predefined symbols, such as the Circle 1 symbol, or you can design your
    own symbols.





    • Click Color. The symbol selector dialog box appears. You
      can select one of the predefined colors from this palette or
      click more colors to mix your own colors using any of the
      color models.
    • Choose a bright Yellow and click OK to close the
      symbol selector box.
    • Click the Background button in the Properties box, located
      under the Template button).
    • Choose No color and set the outline width to 0.00. This
      way, we won’t see the park boundaries behind the the
      graduated symbols. This makes the map less confusing to
      look at and not so messy.
    • Click OK on the Properties dialog box to see your map with the new polygon symbols.
    • You can now see a pattern of larger parks in counties with smaller populations per square mile and smaller parks in counties with larger populations per square mile.
    • Once you’ve set the symbolization for a layer to your satifaction, you can preserve it for later use by saving the map or by saving the layer as its own layer file (.lyr), such as miparks_sqmi.lyr.



    Adding Labels to a Map
    • The map is currently labeled with cities, but let’s change it to label the counties instead. First we need to take the cities labels off.
    • Right-click the cities layer and click Label Feature. This will uncheck it and turn the labels off in the map.
    • Right-click the micounties layer and click Properties (to open the layer properties dialog box).
    • Click on the Labels tab near the top of the Layer Properties dialog box.
    • Check the box to ‘Label features in this layer’.
    • Click the dropdown arrow next to Label field and choose NAME.
    • Change the size of the Text Symbol to 7.
    • Click OK.

    Working with the Map Layout

    • You can now change the map to Layout View in order to add a Title, North Arrow, Legend, etc. to make it suitable for printing or exporting to another format to share with others























    Click ‘View’ and click ‘Layout View’.
    • Now you can see the map
      on a virtual page. The
      layers of the data appear in a
      data frame on the page.
      Data frames are a way of
      organizing the layers you
      want to see together on a map.
    • There is always at least one data frame
      on a map. This one is called Layers;
      you can see its name at the top of the
      ArcMap table of contents.
    • You can add additonal data frames to a map to compare two areas side by side or to show overviews or detailed insets.
    • You can see all of the data frames on your map in Layout View. If you switch back to Data View, you only see the active data frame. The active data frame is shown in boldface type in the table of contents.
    • You can change the shape and position of data frames on the page; add other map elements, such as legends, scalebars, titles, etc.; and change the page size and orientation.
    • The Layout toolbar is added to the ArcMap interface when you choose Layout view.




    • You can use the tools on the Layout toolbar to change the size and position of the virtual page or to zoom in or out of the virtual page.
    • You can also use the Tools toolbar in Layout view to change the extent of the layers that are shown in the data frame.
    • Click ‘File’ on the main menu and choose ‘Page and Print Setup’.
    • Click Landscape under Paper and Page and click OK.
    • Click the Select Elements(Black Arrow) button on the Tools toolbar

    • Click the data frame to select it. It should now be outlined with a dashed line and has selection handles at its corners and edges.
    • Click the center of the data frame and drag it to the upper-left corner of the layout.
    • Point to the select handle at the lower-right corner of the data frame and click and drag the corner up and to the left.
    Adding a Scale Bar
    • On the Insert menu, click Scale Bar. The Scale Bar Selector dalog box appears.
    • Click one of the scalebars and click OK.
    • Click the scalebar and drag it to the empty space below the left side of the data frame.
    Adding a North Arrow
    • Click the Insert menu and click North Arrow. The North Arrow Selector dialog appears
    • Click one of the North arrows and click OK.
    • Click the North arrow and drag it to the empty space below the data frame and to the right of the scalebar.
    Saving a Map

    • Click File and click Save As.
    • Navigate to the data folder in C:\temp\ArcGIS_Workshop\Exercises.
    • Type “Michigan County Parks”. Click Save.
    • You could now print a copy of this map or Export it to another format such as PDF, JPEG, TIFF, BMP, etc. for sharing with others.
    • File – Print

    • File – Export Map…