Load Layer di ArcGIS
Ini adalah contoh Script VBA di ArcMap, gunanya adalah untuk load shapefile ke Dataframe.
Private Sub LoadMap()
‘definisikan Workspacefactory sebagai sumber data, dalam hal ini adalah shapefile
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
‘definisikan lokasi feature, bisa diganti sesuai lokasi shapefile
Dim pWorkspace As IFeatureWorkspace
‘Ganti drive dan folder tempat file shp anda
Set pWorkspace = pWorkspaceFactory.OpenFromFile(”c:\map”, 0)
‘definisikan tempat load mapnya, dalam hal ini map akan di-load ke active document
‘yaitu gis.mxd yang sedang dibuka.
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
‘definisikan Geographic View
Dim pActiveView As IActiveView
‘definisikan feature dan buka
Dim pClass As IFeatureClass
‘buka parcels.shp
Set pClass = pWorkspace.OpenFeatureClass(”parcels”)
‘jadikan feature yang dibuka di atas sebagai layer baru
Dim pLayer As IFeatureLayer
Set pLayer = New FeatureLayer
Set pLayer.FeatureClass = pClass
pLayer.Name = pClass.AliasName
‘tambahkan layer ke document
pMxDoc.AddLayer pLayer
‘refresh geographic view
pMxDoc.ActiveView.Refresh
End Sub


