Chapter 14 Adding layers to a map - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Chapter 14 Adding layers to a map

Description:

Then, to access data set, you need to create a Workspace Factory. Personal geodatabases are stored in MS Access file format. So, we create a MS workspace factory: ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 11
Provided by: pete7
Category:

less

Transcript and Presenter's Notes

Title: Chapter 14 Adding layers to a map


1
Chapter 14 Adding layers to a map
  • Advanced GIS
  • Week 8
  • 2005 Spring

2
Procedures
  • Create a layer from layer coclass
  • Get data set from folder
  • Associate the data set with the layer
  • Add the layer to a map

3
Create layers from coclass
  • For examples
  • Dim pRLayer as IRasterLayer
  • Set pRLayer as RasterLayer
  • Dim pFLayer as IFeatureLayer
  • Set pFLayer as FeatureLayer

4
Workspace
  • The place the data is stored (folder, access
    file)
  • To get a data set, you should get its workspace
    which you get from a workspace factory.
  • Procedures create a workspace factory, use it to
    get a workspace, and then get the data set you
    want from the workspace.
  • See page 240 for the illustration.

5
Workspace Factory and Workspace
  • WorkspaceFactory is an abstract class with many
    coclasses
  • When you have got a workspace from a
    workspacefacotry, you get a data set from the
    workspace. Dataset, as in workspace factory, is
    an abstract class with many subclasses.

6
Adding geodatabase feature class
  • For example to add feature layer, you need to
    create the layer first.
  • Dim pFLayer As IFeatureLayer
  • Set pFLayer New FeatureLayer
  • Then, to access data set, you need to create a
    Workspace Factory. Personal geodatabases are
    stored in MS Access file format. So, we create a
    MS workspace factory
  • Dim pAWFactory As IWorkspaceFactory
  • Set pAWFactory New AccessWorkspaceFactory

Although you are creating a MS Access workspace,
the variable is declared to IWorkspaceFactory
because of its method OpenFromFile, which
returns IWorkspace
7
Workspace
  • Get workspace
  • Dim pFWorkspace As IFeatureWorkspace
  • Set pFWorkspace pAWFactory.OpenFromFile
    (G\Students\...mdb,0)
  • Get the data by running OpenFeatureClass method
  • Dim FClass As IFeatureClass
  • Set FClass pFWorkspace.OpenFeatureClass(Streets
    )

8
byVal or byRef
  • Set byVal and byRef

9
Associate feature to layer and add layer to a map
  • Associate a feature class with a layer by setting
    the FeatureClass property on IFeatureLayer
  • Set pFlayer.FeatureClass pFClass
  • Finally, add the layer to a map (see different
    method for raster image on page 255)
  • Dim pMxDoc as IMxDocument
  • Set pMxDoc ThisDocument
  • Dim pMap As IMap
  • Set pMap pMsDoc.FocusMap
  • Then, Add the layer with the AddLayer method on
    IMap
  • pMap.AddLayer pFLayer
  • pMxDoc.ActiveView.Refresh
  • pMxDoc.UpdateContents

Move layer pMap.MoveLayer pRLayer,
pMap.LayerCount-1
10
Inheritance
  • Class Inheritance - A class has all the
    interfaces of its superclass. For example,
    FeatureLayer has all the interfaces of it
    superclass Layer.
  • Interface Inheritance one interface inherits
    the properties and methods of another interface.
  • Page 264 shows example
Write a Comment
User Comments (0)
About PowerShow.com